Wicklund
07-11-2003, 08:13 AM
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!!!!
bayman
07-12-2003, 05:12 AM
Try this:
Private Sub Form_Current()
If len(fieldname) = 10
fieldname.InputMask = "999-999-9999"
else
fieldname.InputMask = whatever
End Sub
bayman
07-12-2003, 05:13 AM
Oops, You'll need to add an 'End If' to the above code.
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:
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:
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.