Selasa, 16 Mei 2017

[MS_AccessPros] Comparing 2 dates

 

I have 2 combo boxes that contain a list of dates. One combo box is named "Date Start", the other is "Date End". And the date is in the format like this: mm/dd/yyyy. The row source of the 2 boxes is based on the same query as shown below:

 

SELECT DISTINCT InputDate FROM qryDate ORDER BY EntryDate;

 

I am using the 2 procedures below to compare the 2 dates after users selected the dates from the combo boxes, however sometimes it works correctly and sometimes it doesn't.  For example, 1/8/2017 was selected in the StartDate box  and 1/3/2017 was selected in the EndDate box or vice versa.  I expected the message box will pop up when the error occurs, it does right sometimes but not always.  Is 1/8/2017 greater than 1/3/2017, or  2/5/2017 less than 2/17/2017 ?

 

And here are my procedures for the 2 combo boxes:

 

Private Sub cboStartDate_AfterUpdate()

    If Me. cboStartDate.Value > Me.cboEndDate.Value Then

        MsgBox "Start Date cannot be greater than End Date."

    End If

End Sub

 

Private Sub cboEndDate_AfterUpdate()

    If Me.cboEndDate.Value < Me.cboStartDate.Value Then

        MsgBox "End Date cannot be less than Start Date."

    End If

End Sub

 

 

Phucon

__._,_.___

Posted by: saigonf7q5@yahoo.com
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (1)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.


.

__,_._,___

Tidak ada komentar:

Posting Komentar