In my form I want users to be able to see a Colour or an Animal based on an optionbox AND based on their input. The code I have attempted so far hasnt worked for me, and I think its because I dont understand how to properly format it.
I have tried doing it per number for every colour, I've tried just adding the numbers as possible values and I tried creating an array. No succes however.
For example.
If Optionbutton A
is selected, and the textbox A
value is 1, 4, or 10, then textbox B
will show Blue. But if textbox A
value is 2, 3, 5, or 9 then textbox B
will show Green.
Example 2.
Optionbutton B
, and textbox A
value is 1, 3, 4, 10 or 12, then textbox B
will show Butterfly. But if textbox A
value is 2, 5, 7 then textbox B
will show Caterpie.
Added note, I dont know if this possible with the form, but if the user were to toggle between optionboxes that textbox B would change accordingly.
Private Sub txtboxA_Change()
Dim txtboxA As String
Dim Colourarray As Variant
Blue = Array("1", "4", "10")
Me.txtboxA.MaxLength = 2
'If OptA is selected then pick colour based on textbox value
If Me.OptA.Value = True And Me.txtboxA.Value = "1" Then 'This bit seemed to work, but once I copied this for every number which needs to show green, vba got unhappy at me.
'If Me.OptA.Value = True And Me.txtboxA.Value = "1", "4", "10" Then
'If Me.optA.Value = True And (Poort = "1", "4", "10") Then
'If Me.txtboxA.Value = Colourarray And Me.optA.Value = True Then
Me.txtboxB.Value = "Blue"
End If
End Sub
Value = "1" Or Value = "4"
and so on.