Masks are not very flexible. They are so inflexible, in fact, that they are
borderline useless and tend to annoy users more than help them.
You could make the default value for the control to be (801) and let the user
edit from there, then use a BeforeUpdate handler to validate the input and an
AfterUpdate handler to clean up the formatting if desired. The user can press
F2 to unhighlight the area code and start typing at the next character
position.
Here's some air code...
Private Sub txtPhone_BeforeUpdate(Cancel As Integer)
If IsNull(Me!txtPhone) Or IsEmpty(Me!txtPhone) Then Exit Sub
If Not ( _
Me!txtPhone Like "(###)###-####" Or _
Me!txtPhone Like "(###)#######" _
) Then
Cancel = True
End If
End Sub
Private Sub txtPhone_AfterUpdate()
If IsNull(Me!txtPhone) Or IsEmpty(Me!txtPhone) Then Exit Sub
If Me!txtPhone Like "(###)#######" Then
Me!txtPhone = _
Left$(Me!txtPhone, Len("(###)###")) & _
"-" & Mid$(Me!txtPhone, Len("(###)###") + 1)
End If
End Sub
On 3 Feb 2004 22:21:24 -0800,
ma*******@byu.edu (Mark Lees) wrote:
I want to create an input mask for a phone number and I would like the
area code to always be (801). However, I want the users to be able to
edit it if necessary.
Would it look like this = !"(801) 000\-0000;;_" ?