Phone# Input mask with default

M

MartyO

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
 
A

Arvin Meyer [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)
 
T

Tony Toews [MVP]

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.

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 number input mask with default area code 2
Input Mask Default Value 3
Remove input mask format 4
Access Input Mask for phone number 2
Input Mask 1
Access - Input Mask 2
Area Code 4
Input mask & Default value 3

Top