Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Sorting Dates by Clicking Header/Label on a continuous form

Posted on 2006-11-21
4
Medium Priority
?
357 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 1000 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
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…
Suggested Courses

876 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