Option Group with 2 radio buttons, how turn both off ?

G

Guest

My continuous form has multiple rows each of which has an option group with 2
radio buttons. By default both buttons are unselected. Once a user clicks a
button it is set and the other one is unset. This is all fine. However, I
need a way to turn both buttons off. How can I do this? I've played around
with the events but can find no way to do it. Clicking an already set button
does not trigger the option group click event.
 
G

Guest

Me.GroupName = 0 will do it. (That's a zero.) You'll need the full form
reference, of course, if you're setting it from outide the form.
 
F

fredg

My continuous form has multiple rows each of which has an option group with 2
radio buttons. By default both buttons are unselected. Once a user clicks a
button it is set and the other one is unset. This is all fine. However, I
need a way to turn both buttons off. How can I do this? I've played around
with the events but can find no way to do it. Clicking an already set button
does not trigger the option group click event.

Add another button to the Option Group. Set it's value to 3.
Code the OptionGroup AfterUpdate event:
If Me![GroupName]= 3 Then
Me![GroupName] = Null
End If
 
G

Guest

Thanks for the response.
I already know that - but how do I trigger it with just the two radio
buttons. What event can I use?
 
G

Guest

If I understand your purpose here, which seems to be to turn an
already-clicked button into a momentary toggle leading to a zero state in the
group, I would try placing an If...Then after your Select Case series: if I
am already clicked, set the group to zero:

Private Sub BttnGrp_Click()
Select Case BttnGrp
Case 1
....do this
Case 2
....do something else
End Select
If BttnGrp >0 Then
BttnGrp=0
Endif
 
G

Guest

Just for grins, I did a quick experiment on this. Turns out, you can use the
mouse down event of each radio button and do this:

Private Sub Option1_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
If Me.Frame0 = 1 Then
Me.Frame0 = 0
End If
End Sub

Just change the test value for each button to the Option Value of the
button, So if it is itself, it will set the value of the group to 0 and
deselect all the buttons; otherwise, it will behave normally.
 
G

Guest

Unfortunately, the Click event does not trigger when you click an already set
radio button....
 
G

Guest

I don't want to add a third button, in fact I just got rid of it as
superfluous.

fredg said:
My continuous form has multiple rows each of which has an option group with 2
radio buttons. By default both buttons are unselected. Once a user clicks a
button it is set and the other one is unset. This is all fine. However, I
need a way to turn both buttons off. How can I do this? I've played around
with the events but can find no way to do it. Clicking an already set button
does not trigger the option group click event.

Add another button to the Option Group. Set it's value to 3.
Code the OptionGroup AfterUpdate event:
If Me![GroupName]= 3 Then
Me![GroupName] = Null
End If
 
G

Guest

I thought I had tried that and the events did not trigger... but I'll give it
another try.
-David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top