Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Option buttons on form

Status
Not open for further replies.

Rinnt

MIS
Feb 11, 2002
181
US
Hi all..
Ok there are about a million access forms, but I figure I'll start here =)

I have a form that contains six groupings of three radio buttons:

Score1
N/A, Iron, Halo

Score2
N/A, Iron, Halo
...

I need to make this form store the information to print out on a report. So if Score1 has N/A and Score 2 has Halo it will be reflected on the report. Problem is, I dont know how to do this. I have created a select case like this:


Private Sub fraScore1_Click()
Dim Temp1
Temp1 = fraScore1
Select Case Temp1
Case 1
txtSight1TEST = "N/A"
Sight1 = "N/A"
Case 2
txtSight1TEST = "Iron"
Sight1 = "Iron"
Case 3
txtSight1TEST = "Halo"
Sight1 = "Halo"
Case Else
MsgBox ("Case Select Error. Please contact your Systems Administrator")
End Select

End Subct

End SubSub

This works to the exent when they click a frame containing option buttons, the button will store NA, Iron or Halo in record "Sight"x . Problem is, the option button stays greyed like its still being pushed. When I advance to a different record and come back the buttons are all grey although the correct information is still in the Sight record. Is there a more efficent way to accomplish this? It seems like a very basic task, but I seem to be stuck... thanks in advance.... All I need is to be able to change record values based on option buttons....
 
Here's a link to another thread that I have just recently answered with regards to the basics of how Option Buttons (AKA Radio Buttons) and Option Group Frames works hand in hand.

Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000
When the going gets tough, the tough gets going.
 
Opps, here's the link:

thread702-749792

Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000
When the going gets tough, the tough gets going.
 
rdodge, Thanks for the reply, but unfortunately I was already aware of this information.

I'm quite certian it is my code setting the option group to a string that causes the buttons to gray. However, I need to have a record changed to a string value - not a number.

Any more suggestions?
 
Here's some information directly from the help file on the Option Group Frame object:

---Start Of Quote---

Using the OptionGroup object
If an option group is bound to a field, only the group frame itself is bound to the field, not the check boxes, toggle buttons, or option buttons inside the frame. Instead of setting the ControlSource property for each control in the option group, you set the OptionValue property of each check box, toggle button, or option button to a number that's meaningful for the field to which the group frame is bound. When you select an option in an option group, Microsoft Access sets the value of the field to which the option group is bound to the value of the selected option's OptionValue property.

Note The OptionValue property is set to a number because the value of an option group can only be a number, not text. Microsoft Access stores this number in the underlying table. In the preceding example, if you want to display the name of the shipper instead of a number in the Orders table, you can create a separate table called Shippers that stores shipper names, and then make the ShipVia field in the Orders table a Lookup field that looks up data in the Shippers table.

An option group can also be set to an expression, or it can be unbound. You can use an unbound option group in a custom dialog box to accept user input and then carry out an action based on that input.

---End Of Quote---

I'm not sure if you are using bound forms or not, but suspect you are. Assuming you are, you may need to create a textbox to have it bound to the field instead of the option group frame. You would then use the option group frame's click event to get the text from the Tag property like the following example:

Private Sub ogfSBO_Click()
me.tbxSIGHT1TEST.Locked = False
Me.tbxSIGHT1TEST.Value = Me.ogfSBO.Controls("ldsO" & Me.ogfSBO.Value).Tag
me.tbxSIGHT1TEST.Locked = True
End Sub

In this example, be sure to have your textbox locked as you don't want users trying to modify anything in it.

I took the above example from one of my switchboard forms and made some modifications to it. I work strictly only with UNBOUND forms cause of the issues I have with bound forms currently with regards to programming limitations which doesn't allow for my requirements to be met with bound forms/controls. Notice, each of the controls within the option group frame all has a name that begins with "ldsO", and it's end with it's corresponding Option Value (I.e. ldsO2). One other limitation as I learned, an option group frame can only have up to 20 option buttons in it. I had wanted to have up to 24, but it didn't allow me to put that many in for my switchboard screens. Of course, I could get around that limitation by putting in a second option group frame, then hide the boundary, which then use a rectangle to put in a boundary for the mere appearance for the users, since I work with unbound forms. However, I thought for now, 20 is fine.

Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000
When the going gets tough, the tough gets going.
 
Ron, I'm not sure if Rinnt is having the same problem as me from his description but it sounds close. I have a frame with six options. If they chose option 1, it makes visible another frame with two bound options (yes, no). When I select one of the six options, go to another record and come back to the first record, you can still see what option you chose because the option is "sunken" lower then the rest of the 5 buttons. However, on the yes/no frame, it will not stay down. It "highlights" the option to let you know it is selected and it is sending the bound information to the table, but when you leave and come back to the record, you can't tell if an option was chosen because it did not stay "sunk". I hope that makes sense. Do you understand what is going on? Appreciate your help, JL
 
Ron, that is okay, I figured it out. I had the yes/no in my table, but had changed my yes/no buttons to toggle switches. Once I set the table to text, it worked fine. Thanks anyway, JL
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top