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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Work with option buttons in a frame!!!!!

Status
Not open for further replies.

Gti

Programmer
Jul 23, 2001
99
PT
I have a frame with two option buttons inside, and what i want is when a option button are true(checked) i do one thing and when de other button are true(checked) i do it another.

Anyone to help me!!!!!1

Tkx
:)
 
Hi!

The option group(frame) itself has a value. When the first button is checked the value is one, the second and the value is two and so on. So all you need is a Select statement:

Select Case YourOptionGroup.Value
Case 1
**Code for if the first button is checked
Etc.
End Select

hth
Jeff Bridgham
 
Sorry Jeff but seems don't work. The buttons are inside a frame. The access give me a error (" NOT VALUE ENTERED ")
Can you help me

Tkx
;-)

 
Hi1

Maybe you can post the code you are using, that might help to see what the problem is. One quick question, did you make the frame first or the buttons first?

Jeff Bridgham
 
I make the frame first.

Code..
Private Sub cmdNacional_Click()
On Error GoTo e_cmdNacional_Click

Select Case Frm_Alterar
Case 1
If Chk_QuerPreSeleccao.Value = True Then
MsgBox "Checked"
End If
End Select

e_cmdNacional_Click:
ErrHandle "cmdNacional_Click"
ErrDisplay
Exit Sub

End Sub
 
Hi!

Well, this is what I thought was happening. When you put a check box or a radio button in a frame(Option group), then the check box will not have a value of its own and you cannot test for it. The buttons will have an optionvalue which you can select for yourself but Access will automatically set them at 1 for the first one you place, 2 for the second and so forth. The frame will have as its value the optionvalue of the selected button. So, in your code, you need to leave out the If statement and you should get the results your are looking for.

hth
Jeff Bridgham
 
You don't check the value of the checkboxes in the frame, you check the value of the frame itself. Each checkbox in the frame corresponds to a number (the Option Value property). When you check a box, the frame itself when reviewed will be equal to the option value of the checked box.

So let's say your frame is named "frm_Alterar" and you have a checkbox in it named "Chk_QuerPreSeleccao" with an option value of 1, here's the code.
[tt]
Select Case Frm_Alterar
Case Is = 1
MsgBox "Chk_QuerPreSeleccao is checked!"
Case Else
MsgBox "Option Value " & Frm_Alterar & " is checked!"
End Select
[/tt]
HTH Joe Miller
joe.miller@flotech.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top