By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,316 Members | 1,342 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,316 IT Pros & Developers. It's quick & easy.

Assigning Values to Option Group based on criteria

P: 1
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.
Mar 5 '10 #1
Share this Question
Share on Google+
1 Reply


ADezii
Expert 5K+
P: 8,699
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:
Expand|Select|Wrap|Line Numbers
  1. Dim cbo As ComboBox
  2. Dim lst As ListBox
  3.  
  4. Set cbo = Me![cboCategory]
  5. Set lst = Me![lstParts]
  6.  
  7. If Not IsNull(cbo) And Not IsNull(lst) Then
  8.   If cbo = 2 And lst = 30 Then
  9.     Me![optButton1].OptionValue = 40
  10.     Me![optButton2].OptionValue = 50
  11.     Me![optButton3].OptionValue = 60
  12.     Me![optButton4].OptionValue = 70
  13.     Me![optButton5].OptionValue = 80
  14.     Me![optButton6].OptionValue = 90
  15.   ElseIf cbo = 3 And lst = 10 Then
  16.     Me![optButton1].OptionValue = 100
  17.     Me![optButton2].OptionValue = 200
  18.     Me![optButton3].OptionValue = 300
  19.     Me![optButton4].OptionValue = 400
  20.     Me![optButton5].OptionValue = 500
  21.     Me![optButton6].OptionValue = 600
  22.   ElseIf cbo = 1 And lst = 20 Then
  23.     Me![optButton1].OptionValue = 150
  24.     Me![optButton2].OptionValue = 300
  25.     Me![optButton3].OptionValue = 450
  26.     Me![optButton4].OptionValue = 600
  27.     Me![optButton5].OptionValue = 750
  28.     Me![optButton6].OptionValue = 900
  29.   Else      'Standard/Defaule Values set initially
  30.     Me![optButton1].OptionValue = 1
  31.     Me![optButton2].OptionValue = 2
  32.     Me![optButton3].OptionValue = 3
  33.     Me![optButton4].OptionValue = 4
  34.     Me![optButton5].OptionValue = 5
  35.     Me![optButton6].OptionValue = 6
  36.   End If
  37. End If
Mar 5 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.