I am trying to write an IF clause to compare a From Date and a To Date on an Access Form. If the From Date is greater than the To Date, a message box appears and the user is sent back to the From date to re-enter the data. The message box will appear when the To Date Date Picker Calendar is clicked. I am embedding the Code to start ON Change for the DateTo text box.
The two text boxes are formatted as Short Dates and use the Date Picker to enter the data.
Here is my code:
If DateSerial([Forms]![frmStartOrderDate]!DateTo) < DateSerial([Forms]![frmStartOrderDate]!DateFrom) Then
MsgBox "From Date " & Me.DateFrom & " is GREATER THAN " & Me.DateTo & ". Please Correct!"
Me.DateTo.Value = ""
Me.DateFrom.Value = ""
Currently the Message Box is not appearing when I enter a DateTo less than the DateFrom.
What can I do to correct this?