By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,488 Members | 2,552 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,488 IT Pros & Developers. It's quick & easy.

Input Masks?

P: 58
Hello,

I am trying something and i don't know if it is possible or even how to go about doing it. I have a form with about 6 text boxes on it. most of these, the users are entering ok. I am having problems with two. The user is to enter the Hole number and the other os to enter the bag number (from that hole). The bag number one, i just need to know how to remove spaces from their entries. The other is a little more difficult. There are three possible entry types that they can enter. They are as follows: LDD-###, 120-##-###, and STW-##-###. The problem I am having is I have people (mostly people who barely know how to run a comp) entering in spaces, colons and other various symbols into the text box. Is there a way to check the first three digits and make sure they are entering them in correctly? i hope this makes sense what i am trying to do.

Andrew
Oct 13 '07 #1
Share this Question
Share on Google+
10 Replies


NeoPa
Expert Mod 15k+
P: 31,186
There is quite a bit of helpful explanation of the Input Mask property in the help file so I'll quote it here for you. This covers all the topics you've asked about, but if you still have problems please come back for more. It's an area that few people are familiar with, but quite powerful nevertheless.
Careful with how the field is entered though, there are situations where users get confused as they go to the field and find themselves at the RIGHT hand end rather than at the left. If you handle this though, you should be able to make it nice and operator-proof. Good luck.
InputMask Property
See AlsoApplies ToExampleSpecificsYou can use the InputMask property to make data entry easier and to control the values users can enter in a text box control. Read/write String.

expression.InputMask
expression Required. An expression that returns one of the objects in the Applies To list.

Remarks
Input masks are helpful for data-entry operations such as an input mask for a Phone Number field that shows you exactly how to enter a new number: (___) ___-____. It is often easier to use the Input Mask Wizard to set the property for you.

The InputMask property can contain up to three sections separated by semicolons (;).

Section Description
First Specifies the input mask itself; for example, !(999) 999-9999. For a list of characters you can use to define the input mask, see the following table.
Second Specifies whether Microsoft Access stores the literal display characters in the table when you enter data. If you use 0 for this section, all literal display characters (for example, the parentheses in a phone number input mask) are stored with the value; if you enter 1 or leave this section blank, only characters typed into the control are stored.
Third Specifies the character that Microsoft Access displays for the space where you should type a character in the input mask. For this section, you can use any character; to display an empty string, use a space enclosed in quotation marks (" ").


In Visual Basic you use a string expression to set this property. For example, the following specifies an input mask for a text box control used for entering a phone number:

Forms!Customers!Telephone.InputMask = "(###) ###-####"

When you create an input mask, you can use special characters to require that certain data be entered (for example, the area code for a phone number) and that other data be optional (such as a telephone extension). These characters specify the type of data, such as a number or character, that you must enter for each character in the input mask.

You can define an input mask by using the following characters.

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

Note Setting the InputMask property to the word "Password" creates a password-entry control. Any character typed in the control is stored as the character but is displayed as an asterisk (*). You use the Password input mask to prevent displaying the typed characters on the screen.

For a control, you can set this property in the control's property sheet. For a field in a table, you can set the property in table Design view (in the Field Properties section) or in Design view of the Query window (in the Field Properties property sheet ).

You can also set the InputMask property by using a macro or Visual Basic.

When you type data in a field for which you've defined an input mask, the data is always entered in Overtype mode. If you use the BACKSPACE key to delete a character, the character is replaced by a blank space.

If you move text from a field for which you've defined an input mask onto the Clipboard, the literal display characters are copied, even if you have specified that they not be saved with data.


Note Only characters that you type directly in a control or combo box are affected by the input mask. Microsoft Access ignores any input masks when you import data, run an action query, or enter characters in a control by setting the control's Text property in Visual Basic or by using the SetValue action in a macro.


When you've defined an input mask and set the Format property for the same field, the Format property takes precedence when the data is displayed. This means that even if you've saved an input mask, the input mask is ignored when data is formatted and displayed. The data in the underlying table itself isn't changed; the Format property affects only how the data is displayed.
Oct 13 '07 #2

nico5038
Expert 2.5K+
P: 3,072
Hello,

I am trying something and i don't know if it is possible or even how to go about doing it. I have a form with about 6 text boxes on it. most of these, the users are entering ok. I am having problems with two. The user is to enter the Hole number and the other os to enter the bag number (from that hole). The bag number one, i just need to know how to remove spaces from their entries. The other is a little more difficult. There are three possible entry types that they can enter. They are as follows: LDD-###, 120-##-###, and STW-##-###. The problem I am having is I have people (mostly people who barely know how to run a comp) entering in spaces, colons and other various symbols into the text box. Is there a way to check the first three digits and make sure they are entering them in correctly? i hope this makes sense what i am trying to do.

Andrew
I would like to know or the numbers that are entered are perhaps Productcodes.
If so, then they should be "known" and then it's an option to use a combobox for the selection.
Your sixth textbox is "divided" into two or three "sections". When the LDD-, 120- and STW- are fixed, then you could have the user to select them from a combobox (or by a radiobutton frame) and based on the choice offer the ### or the ##-### field.

Just some thoughts, more information about the what and why of the codes could help...

Nic;o)
Oct 13 '07 #3

P: 58
This db is for a mine and the codes are for drill holes. They are for different areas on site. eg. STW-07-007 is as follows: STW stands for the area, 07 is the year, and 007 is the hole number. 120-07-007 is as follows: 120 is the area, 07 is the year, and 007 is the hole number. LDD-060 is as follows:LDD is for Large Diameter Drills and 060 is the hole (the LDD holes are in the local mine site area so there is no actual area code). I will look up more on input masks and see what i can do to use them. I see I can enter up to 3 different input masks so this may be my answer. But any more help you can be is greatly appreciated

Andrew
Oct 13 '07 #4

P: 58
I am still fairly new with input boxes. Would this be how i would do it?

go into the design section of the table and enter in the following into the input mask

"LDD"-000; "STW"-00-000; "120"-00-000

Like i said i am still new to input masks.

Andrew
Oct 13 '07 #5

nico5038
Expert 2.5K+
P: 3,072
This db is for a mine and the codes are for drill holes. They are for different areas on site. eg. STW-07-007 is as follows: STW stands for the area, 07 is the year, and 007 is the hole number. 120-07-007 is as follows: 120 is the area, 07 is the year, and 007 is the hole number. LDD-060 is as follows:LDD is for Large Diameter Drills and 060 is the hole (the LDD holes are in the local mine site area so there is no actual area code). I will look up more on input masks and see what i can do to use them. I see I can enter up to 3 different input masks so this may be my answer. But any more help you can be is greatly appreciated

Andrew
Hmm, to make it userfriendly I would use a combobox with the Areas, so the user can select the STW / 120 / LDD, etc.
The Areas can be maintained in a separate tblArea and thus users can add new areas when needed. Also they can't put an erroneous area into the database.
The Year can also be a combobox, but I guess 07 (current year) is most widely used and can be set as default value. Finally only the drillhole resides being a 3 digit number.
Just make sure that these three fields are store separately, making it easier for you to report per area and/or year.
For the LDD having no year puzzles me, but you can exclude the Year combobox when LDD is chosen

Getting the idea ?

Nic;o)
Oct 13 '07 #6

NeoPa
Expert Mod 15k+
P: 31,186
The three different sections of the mask (separated by ;) are for different things within the definition of the mask - not for different masks.
I think that Nico's idea is good for the first part where it should be selected from a list of available areas (you can even include the local area option). It would even be possible to use this for the year and Hole numbers, but it may just be easier to define a mask for those parts. A two digit year (where both digits are mandatory and a three digit Hole number (again mandatory digits), can both be created quite easily with the info in the Help (posted).
"\-00\-000;0" would be a starting try for your "-Year-Hole" part of the field. This is with a ComboBox selecting the Area.
Oct 13 '07 #7

P: 58
Thanks for all your help. I will try the drop down box idea, I never thought of that. You guys are such a big help, and quick too

Andrew
Oct 14 '07 #8

NeoPa
Expert Mod 15k+
P: 31,186
No worries Andrew.
Nico is indeed tearing through pretty well every Access question at the moment giving the benefit of his vast experience (He must be between projects :D). I'll have to try to discourage anyone from hiring him, as this is great for TheScripts.
Oct 14 '07 #9

nico5038
Expert 2.5K+
P: 3,072
Sorry NeoPa, I'm not between projects, but had a vacation location with internet connection and some spare time in the evenings <LOL>.

One final tip for Andrew, as the LDD doesn't need a Year, I would use the AfterUpdate of the area combo to hide the year combo when LDD is selected, thus making it easier for the user. Also setting the year combo with the last 10 years can be made automatic using the function Year(Date). By sorting the year descending will offer the most used years first.

Nic;o)
Oct 14 '07 #10

NeoPa
Expert Mod 15k+
P: 31,186
Shame Nico - but enjoy your holiday anyway ;)
@Andrew There is always the possibility of adding a dummy entry into the Area ComboBox (EG "None" or such like) and the code that puts it together can interpret that as being no data.
Oct 14 '07 #11

Post your reply

Sign in to post your reply or Sign up for a free account.