Earlier this week, I wrote about using the pre-defined input masks when defining field properties in Microsoft Access. While the most common formatting options are included, often there is a need for a custom solution.
There are 3 parts to an input mask:
- The characters, placeholders and actual items (such as dashes) that make up the input mask. This part is required.
- A “0″ or “1″, defining whether or not the added characters are saved with the data. If set to “0″, the additional characters are saved with the data – which can add to the size of your database.
- The third part shows what character is used as a placeholder when the field is waiting for data entry. The default option is the underscore, but you can use any character — including a space.
You can build your own custom input mask for any Microsoft Access field using placeholders and characters to define your format.
It’s helpful to look at an existing input mask to understand how the characters work. If we use the example of the phone number mask, it looks like this: (999) 000-000;0;-:
The parentheses and dash will appear in the display as parentheses and a dash. The “9″ character represents an optional number, so the area code is not required for this field. The “0″ represents required numbers.
The “0″ after the semi-colon means that the added characters will be saved with the data. The final dash means that instead of an underscore, a dash will hold the place before data entry occurs.
This table provides you with the available characters so that you can create your own custom masks. For additional assistance, consider taking one of our many Microsoft Access classes!
| Character | Description | Character | Description |
|---|---|---|---|
| 0 | Numbers 0 to 9 required; plus and minus signs not allowed. | & | Character or space required. |
| 9 | Number or space optional; plus and minus signs not allowed. | C | Character or space optional. |
| # | Number or space optional; plus and minus signs not allowed. | < | Converts the following characters to lowercase. |
| . , : ; – / | Decimal point, thousands, date, and time separators. | > | Converts the following characters to uppercase. |
| A | Letter or number required. | ! | Displays characters from right to left, rather than left to right. |
| a | Letter or number optional. | \ | Displays the following input mask character. For example, \* would display *. |
| L | Letters A to Z required. | Password | Displays an asterisk( * ) for each character you type. |
| ? | Letter or number optional. |




