VBA to sort (2)

  • Thread starter Thread starter Martin
  • Start date Start date
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
 
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).
 

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

Similar Threads

VBA to SORT (2) 1
Query Parameter using multiple options 0
VBA to "sort" 1
What's causing error 2465? 4
two sorts VBA, how? 3
'Select Distinct' query in VBA 2
one more bug in a2K7: form order by 5
Count field 4

Back
Top