Button to sort a list

fluidmind

Registered User.
Local time
Today, 08:12
Joined
Jun 30, 2006
Messages
66
Hello there!

This is my very first post on this forum. I started to work with Acces and SQL only two weeks ago, so my questions probably are newbie-stuff, but please bare with me and please help me anyway :-)

In my form I've inserted a list that shows data from one of my tables. The posts are ordered by 'ID' (and I know how to change this). But I want to make a button just right of it, that, when it's clicked, sorts the list by 'first name' instead.

How do I make such one???

// John
 
If you're talking about a listbox, then you have to change the row source in the button click event...

Private Sub SortByFirstNameButton_Click()
Me.List1.RowSource = "Select PersID, Fname, Lname From MyTable Order By Fname"
End Sub

Private Sub SortByLastNameButton_Click()
Me.List1.RowSource = "Select PersID, Fname, Lname From MyTable Order By Lname"
End Sub
 
Thank you so much!

Hey Guys!

Thank you very much both of you. I chose the first presented solution, but the second and more advanced one really helped me understand the concept behind it...

I really appreciate your help!!

John
 

Users who are viewing this thread

Back
Top Bottom