Sort Listbox with a button

ddrew

seasoned user
Local time
Today, 20:25
Joined
Jan 26, 2003
Messages
911
I have a Listbox that I use to find records in the Database. It has two fields, [ShootID] and [ShootDate]. It is curently sorted in the query by [ShootID] but I want the user to be able to change it to sort by [ShootDate] and then back again.

Can someone give me a steer please?
 
Figured this one out after a search!
Code:
Private Sub Sort_Click()
    If Me.List11.RowSource = "SELECT tblShootDates.ShootDateID,tblShootDates.ShootDate FROM tblShootDates ORDER BY tblShootDates.ShootDateID ASC;" Then
        Me.List11.RowSource = "SELECT tblShootDates.ShootDateID,tblShootDates.ShootDate FROM tblShootDates ORDER BY tblShootDates.ShootDate ASC;"
    Else
        Me.List11.RowSource = "SELECT tblShootDates.ShootDateID,tblShootDates.ShootDate FROM tblShootDates ORDER BY tblShootDates.ShootDateID ASC;"
    End If
End Sub
 

Users who are viewing this thread

Back
Top Bottom