Recognising incorrect dates

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I have various date fields mostly formatted as Short date. Problem I have is that if a user enters an incorrect date i.e 31/4/04 it is not flagged as incorrect but juggled to fit - 04/04/1931! I've tried input masks but same thing. I don't really want to use the calendar control so is there a way round this. Had this problem in 2000 but still there in XP. Any help much appreciated

Sheila
 
Unfortunately, there isn't any easy solution. IsDate will return True for
31/4/04, because it's going to do the same manipulations that Access does to
accept that date as 4 Apr, 1931.

You could try using an unbound field for the date, then check the input with
your own function to ensure its accuracy.

Forcing your users to use 4 digit year will help.

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)


Sheila D said:
Hi

I have various date fields mostly formatted as Short date. Problem I have
is that if a user enters an incorrect date i.e 31/4/04 it is not flagged as
incorrect but juggled to fit - 04/04/1931! I've tried input masks but same
thing. I don't really want to use the calendar control so is there a way
round this. Had this problem in 2000 but still there in XP. Any help much
appreciated.
 
The problem of Access spinning the dates around exists in all recent
versions of Access, including 2003.

You could trap it in the BeforeUpdate event of the control if you examine
the Text property of the control, parse it with Left(), Mid(), and Right(),
pass it into DateSerial() and see if it errors.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Sheila D said:
Hi

I have various date fields mostly formatted as Short date. Problem I have
is that if a user enters an incorrect date i.e 31/4/04 it is not flagged as
incorrect but juggled to fit - 04/04/1931! I've tried input masks but same
thing. I don't really want to use the calendar control so is there a way
round this. Had this problem in 2000 but still there in XP. Any help much
appreciated.
 
Back
Top