Asending Order

G

Greg

Hello,
I am opening a form with a docmd.openform .... I would
like to insert code after the docmd that when the form is
opened it is ordered by the last name field in asending
order. How is this done?
Thanks in advance for your help.
 
A

Allen Browne

If you always want the target form to be sorted by last name, then simply
change its RecordSource to a query. In query design, use the Sorting row
under LastName field.

If the target form should only be sorted by LastName after it is opened this
way, you can use its OrderBy property like this:

DoCmd.OpenForm "Form1"
With Forms("Form1")
.OrderBy = "[LastName]"
.OrderByOn = True
End With
 
Top