473,320 Members | 1,694 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,320 software developers and data experts.

Phone Input Masks - Area Code

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 = !"(801) 000\-0000;;_" ?
Nov 12 '05 #1
2 3035
Masks are not very flexible. They are so inflexible, in fact, that they are
borderline useless and tend to annoy users more than help them.

You could make the default value for the control to be (801) and let the user
edit from there, then use a BeforeUpdate handler to validate the input and an
AfterUpdate handler to clean up the formatting if desired. The user can press
F2 to unhighlight the area code and start typing at the next character
position.

Here's some air code...

Private Sub txtPhone_BeforeUpdate(Cancel As Integer)
If IsNull(Me!txtPhone) Or IsEmpty(Me!txtPhone) Then Exit Sub
If Not ( _
Me!txtPhone Like "(###)###-####" Or _
Me!txtPhone Like "(###)#######" _
) Then
Cancel = True
End If
End Sub

Private Sub txtPhone_AfterUpdate()
If IsNull(Me!txtPhone) Or IsEmpty(Me!txtPhone) Then Exit Sub
If Me!txtPhone Like "(###)#######" Then
Me!txtPhone = _
Left$(Me!txtPhone, Len("(###)###")) & _
"-" & Mid$(Me!txtPhone, Len("(###)###") + 1)
End If
End Sub

On 3 Feb 2004 22:21:24 -0800, ma*******@byu.edu (Mark Lees) wrote:
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 = !"(801) 000\-0000;;_" ?


Nov 12 '05 #2
Steve Jorgensen <no****@nospam.nospam> wrote in
news:j7********************************@4ax.com:
Masks are not very flexible. They are so inflexible, in fact, that they
are
borderline useless and tend to annoy users more than help them.

You could make the default value for the control to be (801) and let the
user
edit from there, then use a BeforeUpdate handler to validate the input >
and an
AfterUpdate handler to clean up the formatting if desired. The user can
press
F2 to unhighlight the area code and start typing at the next character
position. On 3 Feb 2004 22:21:24 -0800, ma*******@byu.edu (Mark Lees) wrote:
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 = !"(801) 000\-0000;;_" ?



And to free the user from the task of pressing F2 to unlight the area code
use the SelStart property in the GotFocus property of the control.

E.g.

Private Sub Controlname_GotFocus()
Controlname.SelStart = 100
End Sub
--
Rolf
Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: joemono | last post by:
Hello everyone! First, I appologize if this posting isn't proper "netiquette" for this group. I've been working with perl for almost 2 years now. However, my regular expression knowledge is...
2
by: RD | last post by:
We always have to have an area code but user does not always have to dial the long distance digit 1 before the area code. When user does not have to make long distance call the phone number our...
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...
2
by: ILCSP | last post by:
Hello, I have this Access 2K query that I need to re-create in MS SQL Server 2000, so I'm using the Query Analyzer to test it. One of the Access fields stores the home phone number. In the...
10
by: JackM | last post by:
I'm still working on validating the phone numbers that are entered on a form but have come across a problem I don't understand how to fix. I can handle most instances when it's in regular US...
7
by: laredotornado | last post by:
Hi, Using php 4.4.4, I am looking to parse a US phone number string into 3 smaller strings -- area code, the first part of the phone number (3 digits) and the last part of the phone number (4...
1
by: rudeman76 | last post by:
Hey again, I have a form (columner style) that the user enters in info from bags that come in. once the user selects an area (from a drop down box), this determines the input mask for the next...
3
by: BUmed | last post by:
Hi all, This is my problem. I need to put a (********) mask over a combo box, memo box and a few text boxes. So I want the person to be able to input the data without any mask but once they move to...
6
by: ricoryan | last post by:
I am creating a formmail page and on the input for the phone number I want the form to be slit in three sections for area code, first three digits and last four digits. The catch is, I wan the cursor...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
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: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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...

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.