Making radio (option) buttons toggle 
Author Message
 Making radio (option) buttons toggle

I have a form with a set of option buttons -- one for each listed author of
a document.  The user clicks one to indicate the lead author, or "principal
investigator."  In general, the designation corresponds well with the way
option buttons work, one author is the lead, and sometimes they pass the
title around.

However, we had a case where the lead author decided not to be listed on the
report.  It would be nice to be able to click on the selected option button
and have its value change to zero (unselect it without selecting another
button).  I've tried tinkering with various events (Click, MouseDown,
MouseUp, Change, BeforeUpdate), and I can't get it to produce this behavior.
If I insert a MsgBox() after a MouseUp routine that toggles the Option
button's value, the value of the option button will toggle, apparently
because the MsgBox steals the focus before the Option button has the
opportunity to change back.

I'm assuming that the fact that the Option button has the focus at some late
point (event), its value is forced to -1 (True), no matter how I change the
value at some earlier point.

I tried tossing in a DoCmd.GoTo() to  force the focus away from the Option
button before it had the chance to change back, but the DoCmd caused an
error.  Anyway ... I was able to come up with a workaround to solve the
problem for my users, just not a toggle.  anyone got any brighter ideas than
mine on this score?

thanks,
-Bill



Wed, 08 Jan 2003 03:00:00 GMT  
 Making radio (option) buttons toggle

This is just off the top of my head -- I haven't tried it -- but here are two
possibilities.

The easy one is to add another option button to the group and label it "No
lead author". I don't know what your macro does with the values of the
buttons, but this one could be some sort of "null action".

The other possibility would be to add a "No lead" button but make it hidden
(Visible = False). Then set up the Click procedures for the other buttons so
that if the button is already selected when it's clicked on, the invisible
button becomes set -- thus resetting the clicked-on button and leaving no
visible selected button.

In any case, don't fight the underlying implementation of option button
groups, which intends that exactly one button is always selected.


Quote:
>I have a form with a set of option buttons -- one for each listed author of
>a document.  The user clicks one to indicate the lead author, or "principal
>investigator."  In general, the designation corresponds well with the way
>option buttons work, one author is the lead, and sometimes they pass the
>title around.

>However, we had a case where the lead author decided not to be listed on the
>report.  It would be nice to be able to click on the selected option button
>and have its value change to zero (unselect it without selecting another
>button).  I've tried tinkering with various events (Click, MouseDown,
>MouseUp, Change, BeforeUpdate), and I can't get it to produce this behavior.
>If I insert a MsgBox() after a MouseUp routine that toggles the Option
>button's value, the value of the option button will toggle, apparently
>because the MsgBox steals the focus before the Option button has the
>opportunity to change back.

>I'm assuming that the fact that the Option button has the focus at some late
>point (event), its value is forced to -1 (True), no matter how I change the
>value at some earlier point.

>I tried tossing in a DoCmd.GoTo() to  force the focus away from the Option
>button before it had the chance to change back, but the DoCmd caused an
>error.  Anyway ... I was able to come up with a workaround to solve the
>problem for my users, just not a toggle.  anyone got any brighter ideas than
>mine on this score?

>thanks,
>-Bill



Wed, 08 Jan 2003 03:00:00 GMT  
 Making radio (option) buttons toggle
Hi Bill,

Unfortunately, I don't think you are going to be able to achieve this in the
way you envisage. There are 3 options:

(1) have an extra optionbutton at the end of the list "Don't List Lead
Author" - this is the accepted method.

(2) have a commandbutton ("Clear Selection") that set's all the optionbutton
values to False.

(3) Use checkboxes instead. You can make these behave like option buttons by
adding some code that unchecks the other checkboxes when one is checked. In
the mousedown event of each checkbox, you can test whether it is already
checked - if so, uncheck *all* the checkboxes. If not, check that box, and
uncheck the rest. You'll need to experiment to find which events to use.

--
Hope this helps.
Regards
ibby

Please post replies or follow-ups to the **newsgroup** so that participants
may benefit or contribute.



Quote:
> I have a form with a set of option buttons -- one for each listed author
of
> a document.  The user clicks one to indicate the lead author, or
"principal
> investigator."  In general, the designation corresponds well with the way
> option buttons work, one author is the lead, and sometimes they pass the
> title around.

> However, we had a case where the lead author decided not to be listed on
the
> report.  It would be nice to be able to click on the selected option
button
> and have its value change to zero (unselect it without selecting another
> button).  I've tried tinkering with various events (Click, MouseDown,
> MouseUp, Change, BeforeUpdate), and I can't get it to produce this
behavior.
> If I insert a MsgBox() after a MouseUp routine that toggles the Option
> button's value, the value of the option button will toggle, apparently
> because the MsgBox steals the focus before the Option button has the
> opportunity to change back.

> I'm assuming that the fact that the Option button has the focus at some
late
> point (event), its value is forced to -1 (True), no matter how I change
the
> value at some earlier point.

> I tried tossing in a DoCmd.GoTo() to  force the focus away from the Option
> button before it had the chance to change back, but the DoCmd caused an
> error.  Anyway ... I was able to come up with a workaround to solve the
> problem for my users, just not a toggle.  anyone got any brighter ideas
than
> mine on this score?

> thanks,
> -Bill



Thu, 09 Jan 2003 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Simulate a grid in VB6 with radio button options in a column

2. Radio / Option Buttons

3. validating radio option buttons

4. Option Control (Radio Button)

5. Making Radio Buttons, check boxes , and Frames Transparent

6. Toggle Button Effect on Tollbar Button

7. Toggle Button Effect on Toolbar Button

8. buttons, toggle button, sliders...

9. command button as a toggle button

10. Disable button and change button value at radio

11. Toggle Options on & off

12. reset Toggle btn in Option Grp when, Next Record

 

 
Powered by phpBB® Forum Software