Phone number input mask with default area code

M

MartyO

I can't seem to get the right combination with an input mask that has a
default area code but lets the user change it if necessary.

Any help would be appreciated.
Please pardon if this is a duplicate post. I posted yesterday but can't find
it!

Thanks!
Marty
 
J

John W. Vinson

I can't seem to get the right combination with an input mask that has a
default area code but lets the user change it if necessary.

That's because it cannot be done with an input mask. Input masks are of very
limited functionality; this isn't one of the things they can do.

Any help would be appreciated.
Please pardon if this is a duplicate post. I posted yesterday but can't find
it!

Here are the two answers that your post received. Note that Microsoft's
webpage Notify function is apparently totally useless, and the Search isn't
much better - http://groups.google.com is (ironically) a lot better at
displaying Microsoft's newsgroups. Here are Arvin and Tony's answers from
yesterday:


<Arvin Meyers, MVP>

Instead of an input mask, use the AfterUpdate event to fix the number. Have
the users just enter the digits without any formatting. This function can be
called in the AfterUpdate event:

Public Function FormatPhone(strIn As String) As Variant
On Error Resume Next

If InStr(1, strIn, "@") >= 1 Then
FormatPhone = strIn
Exit Function
End If

Select Case Len(strIn & vbNullString)
Case 0
FormatPhone = Null
Case 7
FormatPhone = Format(strIn, "@@@-@@@@")
Case 10
FormatPhone = Format(strIn, "(@@@) @@@-@@@@")
Case 11
FormatPhone = Format(strIn, "@ (@@@) @@@-@@@@")
Case Else
FormatPhone = strIn
End Select

End Function

Set the default value to you local area code and have the cursor start at
the end of the value in the text box (set that in options)
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.accessmvp.com
http://www.mvps.org/access


MartyO said:
I can not get the right combination to do the following, (maybe it's not
possible). I want to have an input mask for the entire phone number, but I
want the area code to default to our local area code, and if it's
different
than that, the user can change it and then type in the rest of the phone
number.
Is that possible?

Thanks!
Marty


MartyO said:
I can not get the right combination to do the following, (maybe it's not
possible). I want to have an input mask for the entire phone number, but I
want the area code to default to our local area code, and if it's different
than that, the user can change it and then type in the rest of the phone
number.


<Tony Toews, MVP>

You will never, ever have an international phone number that is
outside the USA or Canada?

Also what about phone extensions?

I just give the users a text field.

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
For a convenient utility to keep your users FEs and other files
updated see http://www.autofeupdater.com/
Granite Fleet Manager http://www.granitefleet.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Phone# Input mask with default 3
Area Code 4
Input Mask Default Value 3
Access Input Mask for phone number 2
Formatting issue with imported telephone number! 2
Input Mask 1
input mask for phone number 2
input mask 4

Top