I need help getting a textbox to respond to what the user selects in a combo box. So far the combo box "substrate" has two option (65185 and 65410) with 65185 being the default. If the selected substrate from the cmb is "65185" I would like to limit the following textbox "RollNumber" to a length of 11 characters. But if the substrate "65410" is selected from the cmb I would like to limit the txt length to 13 characters. Here is the code I currently have:
Private Sub txtRollNumber_Click()
If Me.cmbSubstrate = "65185" Then
Me.txtRollNumber.MaxLength = 11
ElseIf Me.cmbSubstrate = "65140" Then
Me.txtRollNumber.MaxLength = 13
End If
End Sub
I know .MaxLength is not recognized by access but I was unable to find anything similar. I am sure my syntax is incorrect, I have only just started getting into coding by hand so I do not know too much...any help is appreciated! Here is a screenshot of the user form: The combo is dropped down from the substrate field, and covers up the roll number text box, but it is right below it.
![]()