I have two unbound fields on a form. The users inputs a Start date in the first field and an end date in the latter. I am using the DateValue to determine that the Start date is prior to the End date. However, what code can I use to determine if both fields have valid dates. I have found that if the users mistakenly (or otherwise) types in an invalid date, my program crashes at my DATEVALUE function because it is trying to process an invalid date. Any help is appreciated.
If you want to make sure that users are inserting proper dates I would create a form with two fields, Start Date and End Date, change the format of your fields to Short Date and then add an input mask like 99/99/0000;0;_ so they are forced to enter a proper date. To verify the dates entered you could use code like this:
If IsNull(Me.StartDate) Then
Msgbox "Please enter a start date."
If IsNull(Me.EndDate) Then
Msgbox "Please enter an end date."
If Me.StartDate >= Me.EndDate Then
Msgbox "The Start Date cannot be equal to or greater " & _
"than the end date."
You may have to change the field names to suit your form but that should get you started.