Table Design  «Prev 

Microsoft Access Input Mask

Specifying Input mask

When you have several people entering data in your Access database, you can define how users must enter data in specific fields to help maintain consistency and to make your database easier to manage. For example, you can set an input mask for a form so that users can only enter telephone numbers in the Swedish format or addresses in the French format. You can set a specific format for the input mask, and select another format so that the same data is displayed differently.

When to use input masks

You can add input masks to table fields, queries, and to form and report controls.
For example, you can add an input mask to a Date/Time field in a table, or to a text box control on a form that you bind to a Date/Time field. You can also add input masks to form controls, such as text boxes, that you bind to table fields that are set to those data types. If you are unfamiliar with data types, see the article Introduction to data types and field properties.
Input masks provide a set format for data entry in a field by using characters and symbols. When you apply an input mask to a field, anyone who inputs data in that field must follow the specific pattern defined by the input mask. For example, if the database user enters a phone number without the area code, in this particular mask,
(___) 555-0187 xt. ___
the user will be unable to save the data until the area code data is added. The exact behavior depends on the how the database designer sets up the input mask.
Input masks provide a large amount of data validation and prevent users from entering invalid data (such as a phone number in a date field). Input masks can also help ensure that users enter data in a consistent way. That consistency can make data easier to find and make it easier to maintain your database.
Remember that you define input masks to control the format in which data is entered in the database but you can apply another format to the same data to change how the data is displayed. For example, your input mask can define dates to be entered in a format such as YYYY.MM.DD, but have the date appear as DD-MMM-YYYY.

Three parts of an Input Mask

Input masks are made up one mandatory part and two optional parts, and each part is separated by a semicolon. The purpose of each part is as follows:
  1. The first part is mandatory. It includes the mask characters or string (series of characters) along with placeholders and literal data such as, parentheses, periods, and hyphens.
  2. The second part is optional and refers to the embedded mask characters and how they are stored within the field. If the second part is set to 0, the characters are stored with the data, and if it is set to 1, the characters are only displayed and not stored. Setting the second part to 1 can save database storage space.
  3. The third part of the input mask is also optional and indicates a single character or space that is used as a placeholder. By default, Access uses the underscore (_). If you want to use another character, enter it in the third part of your mask.
  1. First, a field called SSN is added to the Consultants table. Its data type is Text with a size of 9.
  2. Then, after you click the builder button next to the Input Mask property, the Input Mask wizard start. You then choose the mask to use.
  3. After picking the mask to use, click Finish
  4. When entering information, here is what the input mask for the field will look like.