Recognising incorrect dates

S

Sheila D

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
 
D

Douglas J. Steele

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.
 
A

Allen Browne

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top