Using Input Masks in Access 2010
Synopsis: Input Masks can be used to limit the pattern for the entry of data into a database. They can also make data entry easier.Facebook
Linkedin
With many data fields, there is little pattern to the data that can be entered. For example, if you want users to enter a free text description of something, you wouldn’t want to restrict data entry unnecessarily.
However, some types of data and data entry benefit from being restricted to a pattern. Date fields are a good example of this. You really need what’s entered into a date field to be a valid date.
To restrict the pattern when entering data into a field you can use an Input Mask.
The Input Mask Wizard is one of the features of Access 2010. Using this tool, can both help you to set up Input Masks and illustrate how they work in general. Let’s use it to set up an Input Mask for the Date of Birth field in the tblStudents student table.
Here are tblStudents in Design View.
Note that the Date of Birth field is selected and that the Input Mask property on the General tab is empty.
Click in the Input Mask property and a Build button appears at the right.
Click on the Build button and the Input Mask Wizard appears.
Access 2010 has some sample Input Masks for fields of type Date/Time, and these are shown as options in the first screen of the wizard. Select the second one Short Date.
Then click in the Try It: box and you will see the Input Mask. It indicates where you should type and what the pattern is.
You can see that the input area is divided into three parts by two “/” characters. These correspond to the separators in the Short Date format, so you would enter the month number before the first “/”, the day number between the “/” characters and the year after the second “/”.
If you try to type anything other than a numeric digit in this field it will not be accepted.
If you try to enter an invalid date, such as a month number of 13, you see an error message like this one.
When you’re happy that you have the correct Input Mask, click Next and you will see the second screen in the wizard.
Here you have the option of further customizing the Input Mask. For example, you could change the placeholder character (the one used to indicate where the numeric digits go) from an underscore to something else.
If you do decide to make a change, there is another Try It: box at the bottom for you to test your new Input Mask.
When you’ve made any changes you want to, click Next.
All you have to do now is click on Finish.
The Input Mask appears as a property of the field.
The mask actually has three elements, separated by “;” characters.
• The first is the mask itself.
• The second tells Access 2010 whether to store the separators in the mask itself (“/” symbols in this case) as part of the data. A “0” here indicates that these separators should be stored.
• The third is the placeholder character, which is an underscore in this case.
Note that once you understand Input masks you may be happy to enter them directly without using the Input Mask Wizard at all.