Hi folks.
I have a form, frmHistory, which has 4 command buttons: Sort Title
(cmdSortTitle), Sort Name (cmdSortName), Due Today (cmdDueToday), and
Due List (cmdDueList).
Sort Title and Sort Name uses VBA code, and sorts the form either
ascending or descending, by title and by name respectively.
Due Today and Due List uses macros, and filters the form to display
records of books that are due on the current date and the entire list
of due books respectively.
The reason why I used command buttons to sort the form instead of
toggle buttons is that the toggle buttons would only go through a
"loop" once i.e. I can only click it twice to sort the form ascending
and descending, then it wouldn't work anymore.
The problem is that, while the sort buttons work fine, it doesn't work
once I used either one of or both of the filter buttons. Does anyone
know why? I have included the coding for the buttons below. Thanks for
your help.
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''
Private Sub Form_Open(Cancel As Integer)
Me.OrderBy = ""
Me.OrderByOn = True
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''
Private Sub cmdSortTitle_Click()
Static x
x = x + 1
If x > 2 Then x = 1
Select Case x:
Case 1: Me.OrderBy = "Title"
Case 2: Me.OrderBy = "Title DESC"
End Select
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''
Private Sub cmdSortName_Click()
Static x
x = x + 1
If x > 2 Then x = 1
Select Case x:
Case 1: Me.OrderBy = "MemName"
Case 2: Me.OrderBy = "MemName DESC"
End Select
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''
cmdDueToday: OpenForm
Form Name: frmHistory
Where Condition: ([Return] Is Null) And ([Due]=Date())
cmdDueList: OpenForm
Form Name: frmHistory
Where Condition: ([Return] Is Null)
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''