Solved

Sorting Dates by Clicking Header/Label on a continuous form

Posted on 2006-11-21
4
344 Views
Last Modified: 2008-03-04
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
0
Comment
Question by:mlcktmguy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 250 total points
ID: 17993163
Your code should work... I added it to a sample db, and it worked fine.  Verify that the column you are sorting on is indeed a date field.  Also double check that the clik event code is actually "tied" to the command button... By clicking the "..." next to the On Click event in the form's properties sheet and Selecting "Code Builder" if given that option.
0
 
LVL 61

Expert Comment

by:mbizup
ID: 17993167
>in the form's properties sheet
Should have been "In the command button's property sheet"
0
 
LVL 1

Author Comment

by:mlcktmguy
ID: 17993264
Thanks you, you are absolutely correct.  It is now working.
0
 
LVL 61

Expert Comment

by:mbizup
ID: 17993271
Glad to help ;-)
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question