mlcktmguy
asked on
Sorting Dates by Clicking Header/Label on a continuous form
In my Access 2000 app I have a continuous form with three columns 'TicketNo', 'TicketDate' and 'Status'. The labels for each of these columns in the form header are 'TicketNo_Label', 'TicketDate_Label' and 'Status_Label'. I have logic in the 'click' event of each of the respective headers. The logic is intended to sort the data in the column that has been clicked. If the data is already in ascending sequence it should be sorted to descending sequence. The logic is the same for all three field labels and it works perfectly for 'TicketNo' and 'Status' which are Strings. The logic does nothing to sort the 'TicketDate' field which is a date.
How do I need to modify the following code to sort the date field?
Private Sub TicketDate_Label_Click()
If Me.OrderBy = "TicketDate DESC" Then
Me.OrderBy = "TicketDate"
Else
Me.OrderBy = "TicketDate DESC"
End If
Me.OrderByOn = True
End Sub
For reference, the following logic which is exactly the same except for the field name, works perfectly on the other two fields:
Private Sub Status_Label_Click() '
If Me.OrderBy = "Status DESC" Then
Me.OrderBy = "Status"
Else
Me.OrderBy = "Status DESC"
End If
Me.OrderByOn = True
End Sub
Private Sub TicketNo_Label_Click()
If Me.OrderBy = "TicketNo DESC" Then
Me.OrderBy = "TicketNo"
Else
Me.OrderBy = "TicketNo DESC"
End If
Me.OrderByOn = True
End Sub
How do I need to modify the following code to sort the date field?
Private Sub TicketDate_Label_Click()
If Me.OrderBy = "TicketDate DESC" Then
Me.OrderBy = "TicketDate"
Else
Me.OrderBy = "TicketDate DESC"
End If
Me.OrderByOn = True
End Sub
For reference, the following logic which is exactly the same except for the field name, works perfectly on the other two fields:
Private Sub Status_Label_Click() '
If Me.OrderBy = "Status DESC" Then
Me.OrderBy = "Status"
Else
Me.OrderBy = "Status DESC"
End If
Me.OrderByOn = True
End Sub
Private Sub TicketNo_Label_Click()
If Me.OrderBy = "TicketNo DESC" Then
Me.OrderBy = "TicketNo"
Else
Me.OrderBy = "TicketNo DESC"
End If
Me.OrderByOn = True
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks you, you are absolutely correct. It is now working.
Glad to help ;-)
Should have been "In the command button's property sheet"