Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Error Handling
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Error Handling
Use the IsDate function:
If IsDate(TheDate) Then "Do something" End If "bw" wrote: 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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Error Handling
One way:
If IsDate(TheDate) Then Me![Calendar1].Value = TheDate Else MsgBox "Enter a valid date" End If In article , bw wrote: 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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Error Handling
Thank you both, Chris and JE.
I should have known this... Bernie On Sun, 20 Jun 2004 11:19:15 -0600, JE McGimpsey wrote: One way: If IsDate(TheDate) Then Me![Calendar1].Value = TheDate Else MsgBox "Enter a valid date" End If In article , bw wrote: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Error Handling | Excel Discussion (Misc queries) | |||
Error handling | Excel Programming | |||
Error Handling | Excel Programming | |||
Error Handling | Excel Programming | |||
Error handling | Excel Programming |