To programmatically sort records on a table, a query, or
a form, etc, call its OrderBy() method and pass it the name of the
column on which the sorting would be based. After calling OrderBy(),
access its OrderByOn Boolean property and set its value to True.
Here is an example:
Private Sub cmdSortByLastName_Click()
OrderBy = "LastName"
OrderByOn = True
To remove the sorting, access the OrderByOn and
set its value to False.