473,396 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Option Group Radio Buttons

Howdy all,
New member, first post.
I've got a form designed to be a scorecard for quality assurance monitoring in a customer service call center. The person I'm kaing the database for wants radio buttons for answering the questions - Yes, No and N/A. I'm good with this.....
The other piece to it is that he wants a way to assign a number value to each radio button to "weight" a particular question differently than other questions.
I can set the OptionValue of any radio button to what ever value he might want, but how to I make it so that he can do it simply? My thought is to have text boxes (hidden until a button "Set Score Weights" is clicked) that would hold what ever values he has chosen.
Is there a way to somehow pass the value of a textbox to set the OptionValue of a radio button? Would the textbox need to be associated with a table?
Would it be simpler to convince bossman to choose some values and do weighting in a "Score" field?
I'm really at a loss as to how to get this done cleanly.
Please help
Nov 19 '08 #1
5 4838
ADezii
8,834 Expert 8TB
I'll show you how this can be done for just one Radio Button, and you can figure it out for the other 2. Let's assume that txtSetNAValue will contain the new Option Value for the Button appropriately named optNA. The following code will point you in the right direction, but has 1 Logic Bug and 1 potential problem. I'm going to bed right now, but if you need further help, either in figuring out what the Bug or Problem may be, or any questions regarding the code, either myself or one of the other Experts/Moderators/Members will be happy to Reply.
Expand|Select|Wrap|Line Numbers
  1. Dim lngNAOptValue As Integer
  2.  
  3. 'Must contain a Value, and it must be a Number (LONG)
  4. If IsNull(Me![txtSetNAValue]) Or Not IsNumeric(Me![txtSetNAValue]) Then
  5.   MsgBox "Invalid Entry for Option Value for N/A", vbExclamation, "Invalid Entry"
  6.     Exit Sub
  7. Else
  8.   lngNAOptValue = CLng(Me![txtSetNAValue])     'Must be a Whole Number (LONG)
  9. End If
  10.  
  11. 'Set an Acceptable Range of Values, if an entry goes outside of
  12. 'this Range, enter a Default Value
  13. If lngNAOptValue < 1 Or lngNAOptValue > 500 Then
  14.   Me![optNA].OptionValue = 275       'Assign Default
  15. Else
  16.   'If you get here, you have a Whole Number (LONG) within
  17.   'the Acceptable Range, so use it
  18.   Me![optNA].OptionValue = lngNAOptValue
  19. End If
Nov 20 '08 #2
I like the way you help!
I enjoy figuring things out on my own when I can.....I'm glad you left me some stuff to think through.
I haven't tried the code yet (got another fire burning....) but I see something that brings up a question. Will the values in the textboxes stay there? Wouldn't they go away if he shut down the DB and restarted?....or does this code assign the textboxes "default value"?
Part two.....I've got 25 questions, each of which has the option group for answering. Is there a way to write the code once for one option group and have the form loop through the optionGroups and textboxes to get values whent he form is loaded or something?
Nov 24 '08 #3
ADezii
8,834 Expert 8TB
Wouldn't they go away if he shut down the DB and restarted?
Yes they would go away, meaning the new Values would not persist. If you wanted the new Values to persist, try Opening the Form in Design Mode, make the necessary changes, then Close and Save the Form.

Is there a way to write the code once for one option group and have the form loop through the optionGroups and textboxes to get values whent he form is loaded or something?
Here is code that will loop through all the Controls in a Form, if it comes across an Option Group, it will print the Option Group Name as well as the various Options within each Group. I have also demonstrated some sample output for you along with the code.
Expand|Select|Wrap|Line Numbers
  1. Dim ctl As Control
  2. Dim ctl2 As Control
  3.  
  4. For Each ctl In Me.Controls
  5.   If ctl.ControlType = acOptionGroup Then
  6.     Debug.Print ctl.Name
  7.     For Each ctl2 In ctl.Controls
  8.       If ctl2.ControlType = acOptionButton Then
  9.         Debug.Print "  |-- " & ctl2.Name
  10.       End If
  11.     Next
  12.   End If
  13. Next
OUTPUT:
Expand|Select|Wrap|Line Numbers
  1. fraTest
  2.   |-- optYes
  3.   |-- optNo
  4.   |-- optNA
  5. optTest
  6.   |-- Option1
  7.   |-- Option2
  8.   |-- Option3
  9.   |-- Option4
  10.   |-- Option5
  11.   |-- Option6
Nov 24 '08 #4
@ADezii
This would negate the "ease" I'm trying to establish. The boss wants to be able to change the values as he see fits, WHEN he sees fit. He would expect the values he inputs on 12/1/08 to remain until......1/17/09 when he decides the values should be adjusted. He doesn't have the know-how, or time to open th form in design view, change default values for 50 textboxes, then save and re-open for use.
What I understand so far is that the code you gave me (which, btw, totally solved another little issue I was having! thank you!) will loop through textboxes for values to use for assigning to the controls in the option groups - assuming someone has entered values into those textboxes once the form was loaded (though, you did make a few lines for default values in the code....).
I think I've got a thought though......would this work?
I've got a form with radio buttons that need to obtain their values independant of the default settings (0,1,2 etc). You gave me code to do that, and code for some nice looping - both of which are housed in the OnOpen or whatever event for the form. Said textboxes are linked to a table that just has the numbers Mr. Bossman has chosen. The button he would click to change those values when he wants would open a form/subform doohickey linked to the table with the numbers - he can change the numbers and a record (perhaps with a date stamp) would be made for each change he does so he can konw how he came up with a score at a particular time......
I'd leave the coded defaults that you wrote in, as a precaution of sorts, and I'd have my values that won't change until bossman wants them to - and I'd have a date stamped record to show the numbers if he flubs somehow!
is this sloppy?
Nov 25 '08 #5
ADezii
8,834 Expert 8TB
This would negate the "ease" I'm trying to establish. The boss wants to be able to change the values as he see fits, WHEN he sees fit. He would expect the values he inputs on 12/1/08 to remain until......1/17/09 when he decides the values should be adjusted.
Expand|Select|Wrap|Line Numbers
  1. As explained previously, to have the Default Values persist, you must Open the Form in Design Mode, 
  2. modify the Defaults, Close the Form, and Save changes, as in:
  3. Dim lngNAOptValue As Integer
  4.  
  5. 'Must contain a Value, and it must be a Number
  6. If IsNull(Me![txtSetNAValue]) Or Not IsNumeric(Me![txtSetNAValue]) Then
  7.   MsgBox "Invalid Entry for Option Value for N/A", vbExclamation, "Invalid Entry"
  8.     Exit Sub
  9. Else
  10.   lngNAOptValue = CLng(Me![txtSetNAValue])     'Must be a Whole Number (LONG)
  11. End If
  12.  
  13. 'Set an Acceptable Range of Values, if an entry goes outside of
  14. 'this Range, enter a Default Value
  15. If lngNAOptValue < 1 Or lngNAOptValue > 500 Then
  16.   DoCmd.OpenForm "frmYourFormName", acDesign
  17.     Forms!frmYourFormName![optNA].OptionValue = 275       'Assign Default
  18.       DoCmd.Close acForm, "frmYourFormName", acSaveYes
  19. Else
  20.   'If you get here, you have a Whole Number (LONG) within
  21.   'the Acceptable Range, so use it
  22.   DoCmd.OpenForm "frmYourFormName", acDesign
  23.     Forms!frmYourFormName![optNA].OptionValue = lngNAOptValue
  24.       DoCmd.Close acForm, "frmYourFormName", acSaveYes
  25. End If
What I understand so far is that the code you gave me (which, btw, totally solved another little issue I was having! thank you!) will loop through textboxes for values to use for assigning to the controls in the option groups - assuming someone has entered values into those textboxes once the form was loaded (though, you did make a few lines for default values in the code....).
No! The code will Loop through all Controls on a Form and if it finds an Option Group, it will list the Controls within that Group along with the Name of the Option Group. The rest I leave to you.
Nov 25 '08 #6

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

Similar topics

3
by: Edward | last post by:
I have a data entry form that allows the user to navigate around entirely using the keyboard. However, it contains various option button controls which are in the tab order. Whenever they are...
2
by: Mokoena | last post by:
How do I get radio buttons to work in HTML, so that only one in a group can be selected at a time? How do I get the value returned from them? How do I reference them in JavaScript? What value is...
1
by: Rick | last post by:
After being frustrated with this issue on several occasions I think I found the secret sauce for solving the issue after reading a few different messages about what others thought and trying a...
19
by: What-a-Tool | last post by:
I have a school project (ASP) in which I have to call three different ASP pages from three different and identical (except for the form "action", obviously) HTM pages. This I have no problem with....
6
by: Robert | last post by:
Hello. I have been trying out the Lebans ToolTip Classes at http://www.lebans.com/tooltip.htm, to display "balloon" style help tips in a form. The classes I am using are located at...
11
by: MLH | last post by:
Why is that? If I choose the tiny check boxes which are hard to hit with a mouse, it works fine. But option buttions, shich can be sized big enough for people with limited sight and dexterity...
20
by: PC Datasheet | last post by:
How can the label for a checkbox and the labels for the options in an option group be addressed? When a checkbox gets the focus, Access draws a dotted box around the label. When an option group...
2
by: NishSF | last post by:
Would anyone have any suggestions/javascript code so that if one clicks the Radio Button "Yes" below he has the option of selecting any of the six CheckBox below. If the user clicks on Radio Button...
3
by: Sin Jeong-hun | last post by:
Suppose there are 4 radion buttons on the form. There's no groupbox or panel to seperate them. By default, the 4 radio buttons are mutually exclusive. Is it possible to group them into two groups?...
7
by: moksha | last post by:
Hi, I am new to javascript and i am facing a problem in coding. plz help me out. I am using javascript for dynamically creating a table row which contains text boxes and radio...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.