Date issue

  • Thread starter Thread starter gr
  • Start date Start date
G

gr

Hi,
I have two date fields, begining date and end date. If the
user types a wrond date ex. 31/05/2003 (April is a 30 day
month), an error is generated. How can I handle this error
in order to tell the user he is typing an invalid date or
automatically change to the closest right date
ex. user types 02/30/2003
change to 02/28/2003 or 02/29/2003, also how can I manage
leap years?

thx
 
Use the isdate() function to check for a valid date and take appropriate action. You might consider putting code in the after update event.

If the date is entered in a text box called text1 and you used the after update event it would look something like this:

if not isdate(text1) then
msgbox "Not a valid date"
cancel = true
end if

Scott Shearer, MCSD, MCDBA
*****msshearer@@@hotmail.com*****



----- gr wrote: -----

Hi,
I have two date fields, begining date and end date. If the
user types a wrond date ex. 31/05/2003 (April is a 30 day
month), an error is generated. How can I handle this error
in order to tell the user he is typing an invalid date or
automatically change to the closest right date
ex. user types 02/30/2003
change to 02/28/2003 or 02/29/2003, also how can I manage
leap years?

thx
 
As for the leap year thing:

If (Year mod 4 = 0) and ((Year mod 100 <> 0) _
or (Year mod 400 = 0)) then
' Leap Year
End if
 
Back
Top