Input mask date syntax-limit input to a number range

G

Guest

How would you write an input mask that limits the possible data entry of day
between 1 to 31, and month 1 to 12?
Bill
 
J

John W. Vinson

How would you write an input mask that limits the possible data entry of day
between 1 to 31, and month 1 to 12?
Bill

Input masks are not capable of doing this - they're too limited.

Why not use a Date/Time field which checks valid dates automatically (e.g. it
will only let you enter February 29 in a leap year)?

To do it on a form, use the control's BeforeUpdate event and cancel the
addition if it's invalid; or you can use a Field Validation rule. For example,
select the month field (which should not use the reserved word Month as its
fieldname) in table design view and put
0 AND <= 12

in the Validation Rule property on the bottom left of the screen, and

"Month must be in the range 1 to 12"

in the Validation Text.


John W. Vinson [MVP]
 

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