Input Masks (Phone Numbers)

Wicklund

Registered User.
Local time
Today, 14:55
Joined
Jun 7, 2002
Messages
56
I am working with a database that someone else set up, that has an input mask for a phone # field. It works fine for US numbers, but we are running into some international #s as well, and it is not working with these #s.

Is there a way to set up the input mask to select either format, based on the number of characters that are entered? Or, will I need to remove the mask, and manually enter the special characters?

Thank you for your help, and have a Great Day!!!!
 
Try this:


Private Sub Form_Current()
If len(fieldname) = 10
fieldname.InputMask = "999-999-9999"
else
fieldname.InputMask = whatever
End Sub
 
Oops, You'll need to add an 'End If' to the above code.
 
sharing solution

Thanks to the above post I put together a simple solution; I'm sharing it in case someone may be looking at this post for the same reason I was.

I created a function because I was going to use it for several phone controls (cell, home, other, etc..)

In a module:
Code:
Function phoneMask(c_name As Control, mask As Boolean)

If mask = -1 Then
    If Len(c_name) = 10 Then
        c_name.InputMask = "(999) 999-9999"
    Else
        c_name.InputMask = ""
    End If
ElseIf mask = 0 Then
    c_name.InputMask = ""
End If

End Function


Then in OnCurrent Event in your form:
Code:
phoneMask Me.control_name, True

Then on GotFocus of the control:
=phoneMask ([control_name], No)

Then on LostFocus of the control:
=phoneMask ([control_name], Yes)


I'm a newbie so post corrections if you see anything wrong with this.
 
I am trying to figure out the international phone number issue and I have no clue what all of the above means (I am really new to access)
Could someone please explain it to me???
Thanks
 

Users who are viewing this thread

Back
Top Bottom