dynamic input mask - on form

  • Thread starter Thread starter mary
  • Start date Start date
M

mary

Hi - I was hoping someone could help me
Currently, I have constructed a db
that needs a changing inout mask based on the preceeding
selection.- (this is in a subform and the subform itself
is essentially a table not a qry - if this matters)

I am input pohone numbers based on the type of phone
for instance
type a input mask should be (_ _ _)_ _ _ - _ _ _ _
type b input mask should be _ _ _ _ _ - _ _ _ - _ _ _ _
type c input mask should be _ _ _ _ _- _ _ _
all numbers no letters
however my problem is that more than one phone type will
be entered -- for example

recordsets in subform
type a (965)324-2342 issued today
type b 12323-213-2133 issued today
and so on

when I go to enter in type B on the second line in the
subform it changes the format on line where it says type
a to the input mask on line type b making it look wrong
it looks like 96532-423-
how do I write the code that gives me a default input
mask of type a but will change to type b or type c if
they are selected first? and won't change the preceeding
record...

please any help is greatly appreciated -- thanks in
advance

oh yes -- how can I change all recorded phone numbers in
the existing database to follow the same format -- is
that possible (the phone numbers are all in the same
field in the db)

again thanks - thanks
 
Instead of an input mask, you might try after event code that checks each
character:

Private Sub TextBox_AfterUpdate()
Dim sTemp As String
Dim sTemp1 As String
Dim sTemp2 As String
Dim i As Integer
Dim iCount As Integer

iCount = Len(Text7)
For i = 1 To iCount
sTemp1 = Mid(Text7, i, 1)
Select Case sTemp1
Case 1, 2, 3, 4, 5, 6, 7, 8, 9, 0
sTemp2 = sTemp2 & sTemp1
Case Else

End Select
Debug.Print i & sTemp1 & " "; sTemp2
Next
If Len(sTemp2) = 9 Then
'Code for (555) 123-12345 or something
ElseIf Len(sTemp2) = 10 Then
'Code for 1 (555) 123-12345 or something
Else
'Some error message code.
End If
End Sub
 
Back
Top