Input mask date syntax-limit input to a number range

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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]
 
Back
Top