open recordset sort order

  • Thread starter Thread starter CN
  • Start date Start date
C

CN

Is there a way that I can sort the results that the
records are returned when using CurrentDb.OpenRecordset
("MyTable").

I have a field in 'MyTable' that I want to use to drive
this sort order so I can loop through the record set based
on that field.

Any ideas would be really appreciated. Thx!
 
The trick is to use an SQL query rather than the table itself in the
recordset definition, and do the sorting in the query, e.g.

strSQL = "SELECT * FROM MyTable ORDER BY MyField"
set rst = CurrentDb.OpenRecordset(strSQL)

HTH,
Nikos
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top