![]() |
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 |
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 |
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 |
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 |
All times are GMT +1. The time now is 10:43 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com