I am trying to write an input mask that displays one mask if the entire field is filled and another if it is filled in a specific partial of the whole. In the case of an American zip(+4), "12345", if 5 digit characters are entered and "12345-6789", if 9 digit characters are entered; in the case of phone number, the variants are: "123.456.7890", if area code is included, "123.4567", if no area code, "123.4567 x123...", if extension is included, and "123.456.7890 x12...", if both are included. Note that just the digit characters are stored, and the punctuation characters are not.
My problem: The zip code field is recreating and locking an actual input mask, based on the initial value of the opening record every time I run form view.
Code:
Option Compare Database
Private Sub ContactPhone_LostFocus()
If Len(Me.ContactPhone) > 7 Then
Me.ContactPhone.InputMask = "999\.000\.0000;;"
Else
Me.ContactPhone.InputMask = "000\.0000;;"
End If
End Sub
Private Sub Zip_LostFocus()
If Len(Me.Zip) > 5 Then
Me.Zip.InputMask = "00000\-9999;;_"
Else
Me.Zip.InputMask = "00000;;_"
End If
End Sub
Any help/leads would be greatly appreciated. I don't want to tell the client "sorry, you can have professional-looking, effective, or easy-to-use, but not any combination of the above."