Format Property

J

Jeff

Hello,

I have a Text Box that & I set the "Format" property to mm/dd/yy to only
allow Dates to be entered.

Which works fine expect for this one case...

If you type in 99/12/04, it thinks 99 is the year & automatially (no Err is
generated) switches the data to 12/4/1999. I have logic to validate &
display a mgsbox if user types in an invalid date but becuase Access is doing
this it accepts it, swaps the data as I mentioned & no err nor my logic to
display an Invalid Date.

Why is Access doing this ?? Please is their a way to stop Access from doing
so, so if user types in 99/12/04, then will consider as an Invalid Date.

It is especially important becuase my logic to validate is in the Form Err &
because again no Err, no display of Msgbox.

Any help would be greatly appreciated.

Thank you,
Jeff
 
A

Allen Browne

HI Jeff

AFAIK, there is no way to turn this nonsense off. Sometimes Access tries to
be too helpful.

You may be able to use the BeforeUpdate event of the control to validate the
entry, e.g.:

Private Sub BirthDate_BeforeUpdate(Cancel As Integer)
If Me.BirthDate > Date Then
Cancel = True
MsgBox "Time travellers not accepted."
End If
End Sub
 

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

Similar Threads

Format Current Date 3
INPUTBOX QUERY-DATE 1
How to enter a date in DD-MM-YYYY format 2
type mismatch error in macro in excel 0
Date formats 1
Date formatting problem on some PCs 2
Vba Date$ 1
Dates swapping 5

Top