I have a table displayed with a continuous form that has header and footer sections. In the header section, instead of Labels as column headers I have Command Buttons that, when pressed, sort the table on that field (column). The following is an example of the code I have for OnClick:
----------------------------------
Private Sub AreaButton_Click()
Static bAsc As Boolean
DoCmd.GoToControl "Area"
If Not bAsc Then
DoCmd.RunCommand acCmdSortAscending
Else
DoCmd.RunCommand acCmdSortDescending
End If
bAsc = Not bAsc
Me!Search.SetFocus
End Sub
--------------------------------------
What I need to know is how to go about providing this functionallity for a multi-field sort. This table contains addresses where the number (Numb), direction (Dir) and street name (Name) are stored in seperate fields. Therefore, to do an "Address" sort I need the "Address" button (there is a single command button located above this group of three fields) to sort the table on [Name]+[Dir]+[Numb] when pressed.
I have tried the obvious...
DoCmd.GoToControl "Name+Dir+Numb"
DoCmd.GoToControl "Name" + "Dir" + "Numb"
DoCmd.GoToControl "Name", "Dir", "Numb"
(stop laughing) ...with less than desirable results.
What's the answer? Please.
Dan
----------------------------------
Private Sub AreaButton_Click()
Static bAsc As Boolean
DoCmd.GoToControl "Area"
If Not bAsc Then
DoCmd.RunCommand acCmdSortAscending
Else
DoCmd.RunCommand acCmdSortDescending
End If
bAsc = Not bAsc
Me!Search.SetFocus
End Sub
--------------------------------------
What I need to know is how to go about providing this functionallity for a multi-field sort. This table contains addresses where the number (Numb), direction (Dir) and street name (Name) are stored in seperate fields. Therefore, to do an "Address" sort I need the "Address" button (there is a single command button located above this group of three fields) to sort the table on [Name]+[Dir]+[Numb] when pressed.
I have tried the obvious...
DoCmd.GoToControl "Name+Dir+Numb"
DoCmd.GoToControl "Name" + "Dir" + "Numb"
DoCmd.GoToControl "Name", "Dir", "Numb"
(stop laughing) ...with less than desirable results.
What's the answer? Please.
Dan