sort fields in a list box

  • Thread starter Thread starter MSD
  • Start date Start date
M

MSD

I'd like a user to be able to change the order of items in a list box by
pressing a command button. So far, I have made it possible to click on a
command button and sort the list in ascending order. I'd like to be able to
click the same button again and have the list sorted in descending order.

I am using a query as the row source for the list box to sort the items. I
wonder if I could pass the "ascending" or "descending" request to my query,
so that I could alternate order each time the command button is pressed.

Anyone know how to do this?

Thanks very much,

Emma
 
Well for sure there is a best way to do it. I long ago did
something like this (air code):

Private Sub cmdButton_Click()
If Me!cmdButton.Caption = "Sort Ascending" Then
Me!cboSomething.RowSource = "SELECT bla bla... ORDER BY
txtSomething ASC; "
Me!cmdButton.Caption = "Sort Descending"
ElseIf Me!cmdButton.Caption ? "Sort Descending"
Me!cboSomething.RowSource = "SELECT bla bla ORDER BY
txtSomething DESC; "
Me!cmdButton.Caption = "Sort Ascending"
End if
End sub
 
Back
Top