Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sort on multi fields w/Command Button

Status
Not open for further replies.

dgriffin

Programmer
May 26, 2001
50
US
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
 
Me.OrderBy = "Field1, Field2, Field3"
Me.OrderBy = True Joe Miller
joe.miller@flotech.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top