Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
bw bw is offline
external usenet poster
 
Posts: 74
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 788
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default 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   Report Post  
Posted to microsoft.public.excel.programming
bw bw is offline
external usenet poster
 
Posts: 74
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error Handling Kevin Excel Discussion (Misc queries) 4 June 19th 08 12:31 AM
Error handling V. Roe Excel Programming 2 February 27th 04 08:04 PM
Error Handling Todd Excel Programming 1 February 13th 04 11:29 PM
Error Handling James Agostinho Excel Programming 1 January 30th 04 06:40 AM
Error handling Tim C Excel Programming 1 October 7th 03 10:00 PM


All times are GMT +1. The time now is 05:11 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"