Error Handling

B

bw

Me![Calendar1].Value = CDate(TheDate)

If "TheDate" is not a valid date, i.e. 00/00/04, how do I keep this code from giving me an
error? Or can I perform some check on "TheDate" to make sure it's "legal" before this
code?

Thanks,
Bernie
 
J

JE McGimpsey

One way:

If IsDate(TheDate) Then
Me![Calendar1].Value = TheDate
Else
MsgBox "Enter a valid date"
End If
 
B

bw

Thank you both, Chris and JE.

I should have known this...
Bernie


One way:

If IsDate(TheDate) Then
Me![Calendar1].Value = TheDate
Else
MsgBox "Enter a valid date"
End If


bw <[email protected]> said:
Me![Calendar1].Value = CDate(TheDate)

If "TheDate" is not a valid date, i.e. 00/00/04, how do I keep this code from
giving me an
error? Or can I perform some check on "TheDate" to make sure it's "legal"
before this
code?

Thanks,
Bernie
 
Top