Date Selection

Johnny Drama

In need of beer...
Local time
Yesterday, 20:04
Joined
Dec 12, 2008
Messages
211
Hi all,

I've got a form that contains two fields for date inputs and then will run a report based upon the dates provided. The code checks to see if the date fields are left blank, and if so, is supposed to pop up a message. Problem is I get a compile error on the line in red. Any ideas?

Thanks

Private Sub report_button_Click()

' Validate the dates
If Not IsNothing(Me.fromdate) Then
If Not IsDate(Me.fromdate) Then
MsgBox "You must enter a valid 'From' date.", vbExclamation, gstrAppTitle
Me.fromdate.SetFocus
Exit Sub
End If
End If
If Not IsNothing(Me.todate) Then
If Not IsDate(Me.todate) Then
MsgBox "You must enter a valid 'To' date.", vbExclamation, gstrAppTitle
Me.todate.SetFocus
Exit Sub
End If
' Make sure To is later or equal to From
If Not IsNothing(Me.fromdate) Then
If Me.todate < Me.fromdate Then
MsgBox "'To' Date must not be earlier than 'From' Date.", _
vbExclamation, gstrAppTitle
Me.todate.SetFocus
Exit Sub
End If
End If
End If
 
What is the purpose of that test? You should only need the IsDate() test.
 
Ah...Thank you once again, pbaldy.
 

Users who are viewing this thread

Back
Top Bottom