473,326 Members | 2,133 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Input Masks?

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
10 7696
NeoPa
32,556 Expert Mod 16PB
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
3,080 Expert 2GB
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
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
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
3,080 Expert 2GB
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
32,556 Expert Mod 16PB
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
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
32,556 Expert Mod 16PB
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
3,080 Expert 2GB
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
32,556 Expert Mod 16PB
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

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

Similar topics

6
by: dude | last post by:
hello how would i make an input mask that only makes the first letter a capitol one? i've been playing around and testing various masks, also tried the wizard, but i've had no luck. could...
2
by: Mark Lees | last post by:
I want to create an input mask for a phone number and I would like the area code to always be (801). However, I want the users to be able to edit it if necessary. Would it look like this =...
4
by: David W. Fenton | last post by:
I'm working on a subform where users put in 24-hour time. On their paper forms, they've been accustomed to referring to midnight as 24:00 (instead of as 0:00, which kind of makes sense from a human...
7
by: F. Michael Miller | last post by:
I have a db with Access front end, sql back, linked tables. I need to be able to change input masks at the table level in code. Any ideas? Thanks!
6
by: Regnab | last post by:
Morning All, I'm trying to ensure that when the user enters a number on a form, the database automatically leaves a space after the 3rd number. I've tried to do this using input masks, but when...
2
by: BerkshireGuy | last post by:
Is there a way to display what the expected format is before entering a control. For instance, if I have the input mask of 99/99/0000;0;#, it shows me ##/##/##, but only when I type the first...
16
by: Filips Benoit | last post by:
Dear all, I have a datefield that sometimes should store hours and minutes too ans use following format and inputmask. dd/mm/yyyy hh\:nn 09/09/0000\ 99:99;0;* Typing date, hour and...
4
by: Dave | last post by:
Hello - Say I have a 32 bit value in data (v:4, r:4, l:8, p:16) unsigned char data; Now, for portabilities sake, I want to use shifts and masks to access these fields, instead of accessing...
12
by: panjap | last post by:
a few days a go i was kindly helped with the trouble i was having on editing lables wjhere i wanted to change access' messages to my own. Below si the qeustion i set a few days agoa , which worked...
5
by: ezechiel | last post by:
hi everyone.. i read on another forum that it is possible to define multiple input masks for a textbox (for example). There is a textbox field where you can enter the name of a machine. The...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.