Solved

Sorting Dates by Clicking Header/Label on a continuous form

Posted on 2006-11-21
4
301 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
  • 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now