I need help alphabetically sorting a continuous list of records on a form. Clicking button SortAZ is supposed to trigger this action.
Details: tblPatients has a list of patient names and their ID numbers. When I create a form based solely on this information, a cmd button is created and works as expected. I want to also allow the user to filter the list by any criteria (say they only remember the first name, but not the ID or last name).
frmPatients has a header above the Detail section. I can't seem to get vba to recognize the fields in the detail section. I have tried several different combinations (see commented lines) and even renaming the Detail section.
Private Sub SortAZClick()
Me.FilterOn = False
Me.OrderByOn = False
'Me.LastName.SetFocus
'Me.OrderBy = "LastName"
'Me.OrderByOn = True
'Me.Detail.OrderBy = "[LastName]"
'Me.Detail!OrderBy = "LastName"
Me.FilterResults!OrderBy = "[LastName]"
'Me.Form.OrderBy = "LastName"
Me.Form.OrderByOn = True
'me.Detail!requery
Me.Requery
End Sub
Oh the horror!!! The problem was in the first line. Should have been Private Sub SortAZ_Click()
Simply leaving out the underscore prevented it from doing ANYTHING.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.