You could use ElseIf. With three options it would look something like this:
If Me.ComboBoxName = "1" Then
Me.TextBoxName.InputMask = "0000-0000-0000-0000#;0;_"
ElseIf Me.ComboBoxName = "2" Then
Me.TextBoxName.InputMask = "0000-0000-0000-00000#;0;_"
Else
Me.TextBoxName.InputMask = "0000-0000-0000-000000#;0;_"
End If
With four options you would repeat the ElseIf line and the one below that.
Select Case is another approach that can be simpler in some cases:
Select Case Me.ComboBoxName
Case "1"
Me.TextBoxName.InputMask = "0000-0000-0000-0000#;0;_"
Case "2"
Me.TextBoxName.InputMask = "0000-0000-0000-00000#;0;_"
Case Else
Me.TextBoxName.InputMask = "0000-0000-0000-000000#;0;_"
End Select
Either one could get unwieldy if there were more than about five choices,
but there are ways of tidying up in such situations.
BTW, I am assuming the combo box selection is text. If it was number you
wouldn't have the quotes around the value.
khashid via AccessMonster.com said:
Awsome, It worked fine..actually I have more then one option but for the
rest
its same. But just for the sake on knowledge what should i do if i had
more
then 1 option and every option has to have a different input mask
That looks like an input mask rather than a format. To change it after
selecting from the combo box you could do something like this in the combo
box After Update event (assuming there are just the two choices as you
have
described:
If Me.ComboBoxName = "1" Then
Me.TextBoxName.InputMask = "0000-0000-0000-0000#;0;_"
Else
Me.TextBoxName.InputMask = "0000-0000-0000-00000#;0;_"
End If
You could do something similar for format.
Hi, I have this urgent question Any help would be appreciated.
[quoted text clipped - 9 lines]
( The difference is only last set of zeros have 5 zeros)