Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing Input Mask in If statements 2

Status
Not open for further replies.

mpnorris

IS-IT--Management
Dec 31, 2002
66
US
I have a form that I would like to limit the number of characters that are allowed to be entered into a text box, based on what is chosen in a dropdown box.

Ex. Depending on the type of product chosen from the dropdown, I want to limit a text box to receive only 10 characters or 14. I have created an input mask through the wizard and it works fine. The problem is when I want to do it based on the dropdown value.

I have been trying to enter If Then Else statements but I don't seem to have the right syntax. The input mask puts ";" and the code thinks it is the end of a statement.

Does anyone have any insight? Any help would be greatly appreciated.
 
Can you explain what the format &quot;>L<??????&quot;. I had created the input mask by the wizard and it worked. I then took the format that was put into the properties box for the input mask and tried to use it to make the adjustments programatically and it did not like the format.

Below is the code that I created but it does not like something about my Then statements. Any input would be greatly appreciated.

If Me.ProductID = conRetail Or Me.ProductID = conRetailLease Then
Me.Correct_Acct_Num.InputMask = &quot;99999999999999;0;_&quot; And Me.Incorrect_Acct_Num.InputMask = &quot;99999999999999;0;_&quot;
ElseIf Me.ProductID = conLease Or Me.ProductID = conLeaseRetail Then
Me.Correct_Acct_Num.InputMask = &quot;99999999999;0;_&quot; And Me.Incorrect_Acct_Num.InputMask = &quot;99999999999;0;_&quot;
Else
Me.Correct_Acct_Num.InputMask = &quot;99999999999999;0;_&quot; And Me.Incorrect_Acct_Num.InputMask = &quot;99999999999999;0;_&quot;
End If
 
Hi, you might try using a Select Case statement in the combo box After Update event. The formatting was truncated to save space:

Private Sub Me.ProductID _AfterUpdate()

Select Case Me.ProductID
Case Is = me.conRetail
Me.Correct_Acct_Num.InputMask = &quot;999999;0;_&quot;
Me.Incorrect_Acct_Num.InputMask =&quot;999999;0;_&quot;

Case Is = conLease
Me.Correct_Acct_Num.InputMask = &quot;999999;0;_&quot;
Me.Incorrect_Acct_Num.InputMask = &quot;999999;0;_&quot;

End Select

-It's a little easer to read anyways.

Hope that helps
 
Thank you very much! I am all set. This was a big help. I appreciate it.
 
You're welcome.
Giving Stars to helpful posts is nice too! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top