I have an option group of 6 radio buttons. I also have a Combo Box, named Category, and a List Box, named Parts. How do I get the value of each of the radio buttons to change based on what is chosen in both the Category and Parts controls? I have a table named Points that contains (among other things) Category, Parts, and then each of the 6 possible values assigned to that combination. Every Parts/Category combination is unique, and therefore is my composite key.
Assigning Values to Option Group based on criteria
Collapse
X
-
-
Assuming your Combo Box was named cboCategory, and your List Box was named lstParts, and your Option Buttons were named optButton1 thru optButton6, then a generic Code Template would be something similar to this:
Code:Dim cbo As ComboBox Dim lst As ListBox Set cbo = Me![cboCategory] Set lst = Me![lstParts] If Not IsNull(cbo) And Not IsNull(lst) Then If cbo = 2 And lst = 30 Then Me![optButton1].OptionValue = 40 Me![optButton2].OptionValue = 50 Me![optButton3].OptionValue = 60 Me![optButton4].OptionValue = 70 Me![optButton5].OptionValue = 80 Me![optButton6].OptionValue = 90 ElseIf cbo = 3 And lst = 10 Then Me![optButton1].OptionValue = 100 Me![optButton2].OptionValue = 200 Me![optButton3].OptionValue = 300 Me![optButton4].OptionValue = 400 Me![optButton5].OptionValue = 500 Me![optButton6].OptionValue = 600 ElseIf cbo = 1 And lst = 20 Then Me![optButton1].OptionValue = 150 Me![optButton2].OptionValue = 300 Me![optButton3].OptionValue = 450 Me![optButton4].OptionValue = 600 Me![optButton5].OptionValue = 750 Me![optButton6].OptionValue = 900 Else 'Standard/Defaule Values set initially Me![optButton1].OptionValue = 1 Me![optButton2].OptionValue = 2 Me![optButton3].OptionValue = 3 Me![optButton4].OptionValue = 4 Me![optButton5].OptionValue = 5 Me![optButton6].OptionValue = 6 End If End If
Comment