Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Text box input mask 2

Status
Not open for further replies.

DBrack

MIS
Mar 12, 2004
33
0
0
US
Hello,

There's a form with a text box field "id". Length of it is 14 including two - chars.

Its format is like AAA-00-0000-AA

The two chars should always display in the text box. The user only enters the alphanumeric number. The text string should be "AAA-00-0000-AA". I tried input mask. It becomes "AAA000000AA".

Also the user may not enter the last two chars. It should become "AAA-00-AAA". The - should not
count when the last two chars are not entered.

If you have any soultions let me know.

Thanks.
 
To get a literal character to show up in the mask (that is, to have the hyphens show up in the finished product, as it were) you have to preceed them in the mask it self with a '\'. The
following mask:

AAA\-00\-0000\-AA

would produce AAA-00-0000-AA in your control.

BTW, the 'A' character in the mask allows for entry of Alpha or Numeric characters. If you need the first three characters and last two characters to be Alpha only, you'd use:

LLL\-00\-0000\-LL

The last part of your posting is somewhat confusing:

"Also the user may not enter the last two chars. It should become "AAA-00-AAA". The - should not count when the last two chars are not entered"

If by this you mean that the user is allowed to not enter the last two characters and in this case you want the last hyphen omitted, I think you've got a problem! I suspect the only way to do this would be to validate your user's input thru VB code.

The foloowing input masks allow for the last two characters to be omitted:

AAA\-00\-0000\-??
LLL\-00\-0000\-??



The Missinglinq

There's ALWAYS more than one way to skin a cat!
 
Thanks for the quick reply... Not sure if I got it right but I setup the input mask as shown above. However, the text field is stripping the - s .. How can I preserve the -s in input mask? Thanks
 
Sorry to take so long getting back to you; having major back problems and can only sit in front of PC for brief periods.

"However, the text field is stripping the - s"

Is stripping the hyphens when/where? When you later go to the record? Where are you placing your input mask? In the properties box of the form or in the design grid of the table itself? How is the data actually stored in the table; is it with or without the hyphens? When you initially do the input mask it asks you if you want the data stored as formatted or not, i.e. 230-70-0987 or 230700987. If it's set to the latter it may later show up without the hyphens.

The Missinglinq

There's ALWAYS more than one way to skin a cat!
 
DBrack,

How about this...
Code:
AAA\-00\-0000\-??[blue];0[/blue]
HTH,

Ken S.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top