yasanthax
asked on
Date Validation and accepting null values on Access Forms
Hi
I have an issue with some code behind a form, which previously worked but seem to break now. The 3 dates on the form are defaulted and users can also manually edit it too in the field directly. The 3 dated validate each other and the recording date has to be between the time started and time signed.
(1) Seems to be a problem with with dates manually entered through the input mask for DD/MM/YYYY HH:MM ie 99\99\9999/99:99:0... The criteria berow fails as macro cannot recognise a date format.
(2) If I insert a CDate() for each field return, there will be a problem dealing with Null Values which should be accepted
Is there a better way of running these validations and also ignoring null values?
'If Me.txtTimeRecorded <> "" Then
' If Me.txtTimeRecorded < Me.txtTimeStarted Then
' MsgBox ("The Recorded Time can not be before the Start Time")
' blnexit = True
' End If
' If Me.txtTimeRecorded > Me.txtTimeSigned Then
' MsgBox ("The Recorded Time can not be after the Time Signed")
' blnexit = True
' End If
'End If
I have an issue with some code behind a form, which previously worked but seem to break now. The 3 dates on the form are defaulted and users can also manually edit it too in the field directly. The 3 dated validate each other and the recording date has to be between the time started and time signed.
(1) Seems to be a problem with with dates manually entered through the input mask for DD/MM/YYYY HH:MM ie 99\99\9999/99:99:0... The criteria berow fails as macro cannot recognise a date format.
(2) If I insert a CDate() for each field return, there will be a problem dealing with Null Values which should be accepted
Is there a better way of running these validations and also ignoring null values?
'If Me.txtTimeRecorded <> "" Then
' If Me.txtTimeRecorded < Me.txtTimeStarted Then
' MsgBox ("The Recorded Time can not be before the Start Time")
' blnexit = True
' End If
' If Me.txtTimeRecorded > Me.txtTimeSigned Then
' MsgBox ("The Recorded Time can not be after the Time Signed")
' blnexit = True
' End If
'End If
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You are welcome!
/gustav
/gustav
ASKER