Phone# Input mask with default

  • Thread starter Thread starter MartyO
  • Start date Start date
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
 
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)
 
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/
 
Back
Top