Guide data entry in Access by using input masks

You can help people enter data correctly into your Access desktop database by providing input masks for fields that contain data that is always formatted a certain way. For example, you can use an input mask to make sure that people enter correctly formatted phone numbers into a phone number field.

An input mask only affects whether Access accepts the data – the mask does not change how the data is stored, which is controlled by the field’s data type and other properties. For more information about how data is stored in Access, see the article Introduction to data types and field properties.

Important:  This article only applies to Access desktop databases. Access web apps and web databases do not support input masks. In an Access web app you can use input hints to guide data entry. For more information on creating Access web apps, see the article creating an Access app.

In this article

About input masks in Access

Characters that define input masks in Access desktop databases

When to avoid using input masks in Access

Create an input mask in Access

Examples of input masks in Access desktop databases

About using input masks for email addresses

About input masks in Access

An input mask is a string of characters that indicates the format of valid input values. You can use input masks in table fields, query fields, and controls on forms and reports. The input mask is stored as an object property.

You use an input mask when it’s important that the format of the input values is consistent. For example, you might use an input mask with a field that stores phone numbers so that Access requires ten digits of input. If someone enters a phone number without the area code, Access won’t write the data until the area code data is added.

The 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:

  • 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.

  • 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.

  • 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.

For example, this is an input mask for a telephone numbers in the U.S. format: (999) 000-000;0;-:

  • The mask uses two placeholder characters, 9 and 0. The 9 indicates an optional digit (which makes it optional to enter an area code), and each 0 indicates a mandatory digit.

  • The 0 in the second part of the input mask indicates that the mask characters will be stored along with the data.

  • The third part of the input mask specifies that a hyphen (-) instead of the underscore (_) is to be used as the placeholder character.

Top of Page

Characters that define input masks in Access desktop databases

The following table lists the placeholder and literal characters for an input mask and explains how it controls data entry:

Character

Explanation

0

User must enter a digit (0 to 9).

9

User can enter a digit (0 to 9).

#

User can enter a digit, space, plus or minus sign. If skipped, Access enters a blank space.

L

User must enter a letter.

?

User can enter a letter.

A

User must enter a letter or a digit.

a

User can enter a letter or a digit.

&

User must enter either a character or a space.

C

User can enter characters or spaces.

. , : ; - /

Decimal and thousands placeholders, date and time separators. The character you select depends on your Microsoft Windows regional settings.

>

Coverts all characters that follow to uppercase.

<

Converts all characters that follow to lowercase.

!

Causes the input mask to fill from left to right instead of from right to left.

\

Characters immediately following will be displayed literally.

""

Characters enclosed in double quotation marks will be displayed literally.

Top of Page

When to avoid using input masks in Access

As useful as they are, input masks are not appropriate in every situation. Don’t use an input mask if following circumstances apply to you:

  • People occasionally need to enter data that doesn’t match the mask. An input mask does not allow exceptions.

  • You plan to use a Date Picker control with a Date/Time field. Input masks are not compatible with the Date Picker control.

Top of Page

Create an input mask in Access

You can either add input masks by using the Input Mask Wizard, or specify masks manually by typing custom masks to the Input Mask field property setting.

Add input masks by using the Input Mask Wizard

This section describes how you can add a predefined input mask to a table field, a query, or a form or report control by using the Input Mask Wizard.

Add an input mask to a table field

Add an input mask to a query

Add an input mask to a form or report control

Create custom input masks

Customize input masks from the Input Mask Wizard

Customize input masks from the field property setting

Add an input mask to a table field

You can use input masks with fields that are set to the Text, Number (except ReplicationID), Currency, and Date/Time data types.

Note: If you use an input mask for a Date/Time field, the Date Picker control becomes unavailable for that field.

  1. In the Navigation Pane, right-click the table and click Design View on the shortcut menu.

  2. Click the field where you want to add the input mask.

  3. Under Field Properties, on the General tab, click the Input Mask property box.

  4. Click the Build button Builder button to start the Input Mask Wizard.

  5. In the Input Mask list, select the type of mask that you want to add.

    Input Mask Wizard in Access desktop database

  6. Click Try it and enter data to test how the mask displays.

  7. To keep the input mask without any changes, click Next.

  8. Select an option for how you want the data to be stored.

  9. Click Finish and save your changes.

Top of section

Add an input mask to a query

  1. In the Navigation Pane, right-click the query that you want to change and click Design View on the shortcut menu.

  2. In the query design grid, place the pointer in the column for the field you want to change.

    You can place the cursor in any row for that field.

  3. Press F4 to open the property sheet for the field.

  4. Under Field Properties, on the General tab, click the Input Mask property box.

  5. Click the Build button Builder button to start the Input Mask Wizard, and then follow the instructions in the wizard.

Top of section

Add an input mask to a form or report control

  1. In the Navigation Pane, right-click the form or report that you want to change and click Design View on the shortcut menu.

  2. Right-click the control that you want to change, and then click Properties on the shortcut menu.

  3. On the All tab, click the Input Mask property box.

  4. Click the Build button Builder button to start the Input Mask Wizard, and then follow the instructions in the wizard.

Top of section

Create custom input masks

Although the Input Mask Wizard provides input masks for most common formatting needs, you may sometimes want to customize an input mask to better suit your needs. Input masks can be customized by either changing the predefined masks from the Input Mask Wizard or by manually changing the Input Mask property for a field where you want the mask applied.

Customize input masks from the Input Mask Wizard

  1. Open the object in Design view and click the field where you want to add the custom input mask.

  2. Click the Build button Builder button to start the Input Mask Wizard.

  3. Click Edit List.

    The Customize Input Mask Wizard dialog box appears.

  4. Enter a new description in the Description text box using characters and placeholders from the table.

  5. Click the Mask Type down arrow and select a suitable mask type.

  6. Click Close. The new input mask displays in the list.

Customize input masks from the field property setting

  1. In the Navigation Pane, right-click the object and click Design View on the shortcut menu.

  2. Click the field where you want to create the custom input mask.

  3. In the Field Properties area, click the Input Mask text box, and then type your custom mask.

  4. Press CTRL+S to save your changes.

For more information about how to define an input mask, click the Input Mask property box, and then press F1. You must manually type the input mask definition for Number and Currency fields.

Top of Page

Examples of input masks in Access desktop databases

The examples in the following table demonstrate some ways that you can use input masks.

This input mask

Provides this type of value

Notes

(000) 000-0000

(206) 555-0199

In this case, you must enter an area code because that section of the mask (000, enclosed in parentheses) uses the 0 placeholder.

(999) 000-0000!

(206) 555-0199
( ) 555-0199

In this case, the area code section uses the 9 placeholder, so area codes are optional. Also, the exclamation point (!) causes the mask to fill in from left to right.

(000) AAA-AAAA

(206) 555-TELE

Allows you to substitute the last four digits of a U.S. style phone number with letters. Note the use of the 0 placeholder in the area code section, which makes the area code mandatory.

#999

-20
2000

Any positive or negative number, no more than four characters, and with no thousands separator or decimal places.

>L????L?000L0

GREENGR339M3
MAY R 452B7

A combination of mandatory (L) and optional (?) letters and mandatory numbers (0). The greater-than sign forces users to enter all letters in uppercase. To use an input mask of this type, you must set the data type for the table field to Text or Memo.

00000-9999

98115-
98115-3007

A mandatory postal code and an optional plus-four section.

>L<??????????????

Maria
Pierre

A first or last name with the first letter automatically capitalized.

ISBN 0-&&&&&&&&&-0

ISBN 1-55615-507-7

A book number with the literal text, mandatory first and last digits, and any combination of letters and characters between those digits.

>LL00000-0000

DB51392-0493

A combination of mandatory letters and characters, all uppercase. Use this type of input mask, for example, to help users enter part numbers or other forms of inventory correctly.

Top of Page

About using input masks for email addresses

Because email addresses vary widely in the number of characters they contain, input masks are not a good tool for ensuring that email addresses are entered correctly. Instead, we recommend using the Validation Rule and Validation Text properties.

The validation rule shown in the following table ensures that the email address is entered with one or more characters, then an “@” sign, then one or more characters, then a period, and then one or more characters. For example, tom@example.com would be allowed, but tom@example,com or tom@example would not. If you enter an email address that doesn’t match the validation rule, Access doesn’t accept the input and displays the message in the Validation Text property. If no text is entered in the Validation Text property box, Access displays a generic message.

Property

Setting

Validation Rule

Is Null Or ((Like "*?@?*.?*") And (Not Like "*[ ,;]*"))

Validation Text (optional)

Please enter the email address with an '@' sign and the full domain name (for example, 'frank@contoso.com').

For more information about using validation rules, as well as step-by-step procedures, see the article Restrict data input by using a validation rule.

Top of Page

Share Facebook Facebook Twitter Twitter Email Email

Was this information helpful?

Great! Any other feedback?

How can we improve it?

Thank you for your feedback!

×