input mask on date field

S

seeker

I have an input mask on a date field hoping that it would not allow incorrect
data. User can enter 04/28/209 without error. What would the validation
rule look like to make sure date was entered as mm/dd/yyyy? I would like to
place this on the field in the table structure.
 
J

John W. Vinson

I have an input mask on a date field hoping that it would not allow incorrect
data. User can enter 04/28/209 without error. What would the validation
rule look like to make sure date was entered as mm/dd/yyyy? I would like to
place this on the field in the table structure.

4/28/209 is a valid date. It was the 16th year of the reign of Emperor
Septimus Severus.

What you might want instead of an input mask (which in my experience will SLOW
DOWN data entry by forcing the user to type 04/29/2009 when they could type
just 4 29 and get the same result) is some *data* validation. For instance you
could use the textbox's BeforeUpdate event on your form (you *are* using a
form... right!?) like:

Private Sub txtDatefield_BeforeUpdate(Cancel as Integer)
If Not IsDate(Me!txtDatefield) Then
MsgBox "Please enter a valid date, e.g. 5/15", vbOKOnly
Cancel = True
Exit Sub
End If
If Me!txtDatefield < #1/1/2000# Then
MsgBox "Please enter a date in the current century", vbOKOnly
Cancel = True
Exit Sub
End If
<etc>
 

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