sort fields in a list box

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top