VBA to sort (2)

M

Martin

Thanks,

However, I also want to know: base on ORDERBY, how to set "A to Z" and "Z
to A" ?

Thanks again !

Martin


-----------------------------------------------------------------------
DoCmd.OpenForm "ABC"
With Forms("ABC")
.OrderBy = "[Field1], [Field2]"
.OrderByOn = True
End With
 
T

tina

an ascending sort (A to Z) is the default, you don't need to specify it. to
sort a field descending, add the abbreviation DESC after the fieldname, as

.OrderBy = "[Field1] DESC, [Field2]"

note that the designation is field-specific, just as it is in a query's
design view.

hth


Martin said:
Thanks,

However, I also want to know: base on ORDERBY, how to set "A to Z" and "Z
to A" ?

Thanks again !

Martin


-----------------------------------------------------------------------
DoCmd.OpenForm "ABC"
With Forms("ABC")
.OrderBy = "[Field1], [Field2]"
.OrderByOn = True
End With

--
Allen Browne - Microsoft MVP. Perth, Western Australia.


-------------------------------------------------------------------------
I want VBA to open FORM "ABC" and sort by "field1" (fisrtly sort), "field2"
(secondly sort).
 
Top