How to validate a date entered on a form

G

Guest

Hello,

I am trying to validate a date. My table is defined with a column with a
data type of Date/Time. On the table design page, the Input Mask is:
"99/99/0000;0;_".
Currently, there is an input mask on the form where the date is entered. It
is:
99/99/0000;0;

Question: Should there be an input maks on both the table design and the
form?
Does one override the other? What is the best practice for this?

Currently, when I enter a date on the form, invalid dates are accepted.
Such as:
"02/45/2007", "14/23/2008", which are obviously not valid.

I need to ensure that for this particular form that the date entered is
greater than the current date. On the form, I have tried a validation rule
of >=Date(). Invalid dates are still being accepted by the form (prior to
saving the record. SAving the record is yet another issue...)

Can anyone point me to some good examples of input masks? I have not found
any that satisify my needs yet.

TIA,
Rich
 
J

Jeff Boyce

Rich

JOPO - just one person's opinion

I've found input masks to be confusing to users. If you click into the
field/control anywhere besides the beginning, the data entered doesn't match
up with the mask.

If you are more concerned with valid dates than the format (and you probably
should be -- Access will store dates in a special way, but you are free to
display it -- i.e., format it -- any way you wish), remove the input mask
and just test for valid dates.

In fact, if you set the underlying table field as a Date/Time data type,
Access will squawk if you enter anything besides a valid date!

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
M

missinglinq via AccessMonster.com

I agree with you, Jeff! Not only does the data not match, but the user then
has to go back and re-enter it all, which is a royal pain! On the very, very
seldom occasion when I find I have to use one, I always use this code:

Private Sub YourTextBoxName_Click()
Me.YourTextBoxName.SelStart = 0
End Sub

When the user clicks on the textbox the cursor automatically goes to the
beginning. And in case the end user has the Access default for "Entering a
Field" set to anything other than "Go to
Start of Field," also use this:

Private Sub YourTextBoxName_GotFocus()
Me.YourTextBoxName.SelStart = 0
End Sub

which does the same thing when tabbing into the textbox.

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

Message posted via AccessMonster.com
 

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

Date Mask auto changes 1916 to 2016 2
Date 4
Data Entry Form 3
Validate a Date 1
Pulling dates 2
Form with filter 4
Need current year 7
Date format with input masks 2

Top