"Literals" in Input Masks

lucour

Registered User.
Local time
Today, 21:38
Joined
Mar 7, 2001
Messages
60
Hi,

I have an MS Access database that tracks backup tapes for Daily LAN backups. These get inputted each day. Each tape is externally labelled with a prefix of 'UTIL10', followed by 3 digit numbers. (ie: UTIL10122). I want the fields to be formatted so that the users only have to enter the last 3 digits.
I have text boxes setup in the form to input these numbers. They are called UT1, UT2, UT3...... Under the properties for each I have an Input Mask, using a literal, set up as such:
"UTIL10"999;;

When I tab to this field, however, and then go to enter 122 the result will show up as UTIL1022 (no 1). You have to press the '1' key twice in a row to get the UTIL10122 to show up. Does anyone know why this is happening?

Thanks.
 
That's really surreal. This is an acknowledged problem with Microsoft Access 2000. See this article for more information, including a workaround with a Macro: ACC2000: Input Mask Fails to Allow Correct Insertion of Numeric Literals (Q208972). Not liking Macros, I've used a small snip of code to get my telephone number slots to default to the digit immediately after the area code.
Code:
Private Sub Home_Phone_Click()
Me.ActiveControl.SelStart = 6
End Sub


Private Sub Home_Phone_GotFocus()
Me.ActiveControl.SelStart = 6
End Sub

I don't recall if the count starts at 1 or 0, but you can use the same thing behind your form to do this.


The poor-man's solution is to not have your batch numbers start that low. Probably not useful for your needs.

You could take off the input mask entirely and change the Format property to >"UTIL10". It will take some getting used to because when you ENTER text, the UTIL10 part will not show, but will display properly after you exit the field. You'll want to add a Validation Rule to make sure they put three characters in: Like "???", and then put in an appropriate Validation Text.

Another possibility would be to actually store the prefix string with the batch number. This is akin to the last solution, but less efficient because it increases the field size and duplicates needless information.

HTH,
David R

[This message has been edited by David R (edited 01-23-2002).]
 
Thanks for the help, David ! I went with your suggestion of eliminating the Input mask and entering the ">UTIL10" in the Format property of each field. This works a lot better than the Input Mask.
One further question . . . the physical labels on the tapes start at UTIL10001 and go to UTIL10150. I want the users only to have to enter a 1 instead of 001, and 95 instead of 095. Is there a way to add or suppress '0' automatically? If I enter just '1' now I get UTIL101 and if I enter 95 I get UTIL1095.

Thanks again.
 
In the BeforeUpdate event of that field you could use Len() to "pad" the answer out to three digits. Another possibility, though I haven't tried it since I'm in the middle of something else, is to make your format >"UTIL10"000

I believe that will have the desired effect without resorting to code. If not, post back and I'll see what I can come up with.

David R
 

Users who are viewing this thread

Back
Top Bottom