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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Input mask problem

Status
Not open for further replies.

medic133

Technical User
Apr 7, 2002
86
US
I have a form with a textbox that stores a phone number. In order to be user friendly, I want to be able to account for the possibility of entering phone numbers with the standard nine numbers (areacode+phonenumber), 1+areacode+phonenumber, 1+areacode+phonenumber+extension, and areacode+phonenumber+extension; all with an input mask for easy readability. I can set the input mask in the afterupdate function of the textbox with no problem according to the following code:

'Set input mask to reflect correct phone number.
If Left(phonenum,1)=1 And Len(phonenum)>10 then
Me!phonenum.inputmask="9-999-999-9999-99999"
ElseIf Left(phonenum,1)=1 then
Me!phonenum.inputmask="9-999-999-9999"
ElseIf Left(phonenum,1)<>1 and Len(phonenum)>10 then
Me!phonenum.inputmask=&quot;999-999-9999-99999&quot;
Else
Me!phonenum.inputmask=&quot;999-999-9999&quot;
End If

My problem is when I retrieve records through the navigation bar, the input mask is lost. I've tried setting the same code in the form activate and form load sections, but cannot get it to work. Any suggestions on how to do this? Thanks in advance.
 
Gerenally, you do not store mask data in your database. The Mask should only be for viewing. When the user enters the phone number, it should be strictly numbers. Also, you should force the user to enter the number in a consistant way, like always including the area code and never putting the 1 at the beginning since that is a given if it is long distance, etc..
 
Thanks anyway! I was able to accomplish what I wanted by rewriting the code!
 
I was wondering if you could post what changes you made when you re-wrote the code. I am wanting to do something very similar to what you have done, but could use your re-write. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top