sorting by multiple fields in dao recordset

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a module in which I need to sort the recordsets by two fields before
looping. The recordset.sort = "[field1]" works for a one field sort. What
is the syntax for sorting by field1 then by field2?

Thanks,

LAF
 
Separate the field names with commas:

recordset.sort "[Field1], [Field2]"

Is there some reason, though, that you can't sort the recordset when you
open it? That's usually faster.
 
LAF said:
I have a module in which I need to sort the recordsets by two fields before
looping. The recordset.sort = "[field1]" works for a one field sort.
What
is the syntax for sorting by field1 then by field2?

I really doubt that you want to "sort the recordsets... before looping". I
suspect you want to open a recordset in which the records will be sorted in
the order you desire.

There are multiple options of which two are: (1) Base your recordset on a
query that sorts on those fields, or (2) Add an ORDER BY clause to the SQL
statement you are using to define the recordset, that includes both fields.

Larry Linson
Microsoft Access MVP
 
Back
Top