By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,665 Members | 2,180 Online
Bytes IT Community
Submit an Article
Got Smarts?
Share your bits of IT knowledge by writing an article on Bytes.

Input Masks

ADezii
Expert 5K+
P: 8,607
The following characters define an Input Mask:

Character - Description
0 - Digit (0 to 9, entry required, plus [+] and minus [] signs not allowed).
9 - Digit or space (entry not required, plus and minus signs not allowed).
# - Digit or space (entry not required; spaces are displayed as blanks while in Edit mode, but blanks are removed when data is saved; plus and minus signs allowed).
L - Letter (A to Z, entry required).
? - Letter (A to Z, entry optional).
A - Letter or digit (entry required).
a - Letter or digit (entry optional).
& - Any character or a space (entry required).
C - Any character or a space (entry optional).
. , : ; - / Decimal placeholder and thousand, date, and time separators. (The actual character used depends on the settings in the Regional Settings Properties dialog box in Windows Control Panel).

< - Causes all characters to be converted to lowercase.
> - Causes all characters to be converted to uppercase.

! - Causes the input mask to display from right to left, rather than from left to right. Characters typed into the mask always fill it from left to right. You can include the exclamation point anywhere in the input mask.

\ - Causes the character that follows to be displayed as the literal character (for example, \A is displayed as just A).

Examples:
LLLLLL - 6 Letters [A-Z] are 'required'
AAAAAA - 6 Letters or Digits are 'required'
NOTE: Select the Input Mask Field for a Field in Table Design View on the bottom Pane and press F1
Jan 24 '07 #1
Share this Article
Share on Google+
1 Comment


missinglinq
Expert 2.5K+
P: 3,532
A good point to remember when using input masks is that the user may not always arrive at the control by tabbing to it from the previous control, but may click on the control. If a mask is being used and the user doesn't click to insert the cursor at the very beginning of the text box, he/she may start to enter data without realizing that they're not at the beginning. When they leave the control they'll get an error message because the data wasn't entered as the input mask dictated. They'll then have to go back and re-enter the info. The way to avoid this is to use something like this:

Expand|Select|Wrap|Line Numbers
  1. Private Sub YourControlName_Click()
  2.     YourControlName.SelStart = 0
  3. End Sub
Even tabbing to the control can be problematic if in the Options for the database the default behavior for "Entering Field" is set to anything other than "Go to start of field." The answer to this is to set the cursor to the beginning of the field:

Expand|Select|Wrap|Line Numbers
  1. Private Sub YourControlName_GotFocus()
  2.     YourControlName.SelLength = 0
  3. End Sub
May 22 '07 #2