Solved

Sorting Dates by Clicking Header/Label on a continuous form

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
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…
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…

749 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