A
Allen Browne
The simplest way to do this is just to set the OrderBy property of your form
to the name of a field. Remember to set OrderByOn as well.
This kind of thing:
Private Sub cmdSortBySurname
Me.OrderBy = "Surname"
Me.OrderByOn = True
End Sub
For a more efficient approach you could create the SQL string on the fly,
and assign it to the RecordSource of the form.
For reports, see:
Sorting Records in a Report at run-time
at:
http://members.iinet.net.au/~allenbrowne/ser-33.html
to the name of a field. Remember to set OrderByOn as well.
This kind of thing:
Private Sub cmdSortBySurname
Me.OrderBy = "Surname"
Me.OrderByOn = True
End Sub
For a more efficient approach you could create the SQL string on the fly,
and assign it to the RecordSource of the form.
For reports, see:
Sorting Records in a Report at run-time
at:
http://members.iinet.net.au/~allenbrowne/ser-33.html