Format Property

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

Guest

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
 
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
 
Back
Top