Option Group - Clear Yes/No

  • Thread starter Thread starter Stu
  • Start date Start date
S

Stu

I have an option group with two option button choices "Yes" (optionValue =
-1) and "No" (optionValue = 0) bound to a Yes/No field in a table.

If the user clicks a Clear button I want both the Yes and No option buttons
in the option group to be unchecked. Is there a way to code this or do I
need to change the table field to type Text?
 
Set the Value of the option group to Null.

Say your Clear button is named cmdClear, and has its On Click property set
to [Event Procedure]. Click the Button beside this property. Access opens
the code window, and you set up the code like this:

Private Sub cmdClear_Click()
Me.[Frame1] = Null
End Sub
 
Stu,
Option Groups always have one of the selections set to True. Such
is the nature of the beast...
Actually, binding a boolean field to an Option Group, although it
can be made to work, really doesn't make sense. You're right... the
Option Group is best used for a text field with values of "Yes" or "No."
But... as you can see... making it more complex than it needs to be.

A boolean field is best represented by a single Check Box.
You can code the Check box's Label to indicate "True" or "False"
depending on the selection... if your concern was user clarity.
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
I tried that and the "No" option was checked. I also tried 999 for the frame
and then the "Yes" option was checked.

Allen Browne said:
Set the Value of the option group to Null.

Say your Clear button is named cmdClear, and has its On Click property set
to [Event Procedure]. Click the Button beside this property. Access opens
the code window, and you set up the code like this:

Private Sub cmdClear_Click()
Me.[Frame1] = Null
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.


Stu said:
I have an option group with two option button choices "Yes" (optionValue =
-1) and "No" (optionValue = 0) bound to a Yes/No field in a table.

If the user clicks a Clear button I want both the Yes and No option
buttons
in the option group to be unchecked. Is there a way to code this or do I
need to change the table field to type Text?
 
I'm following a client's specs here, so it's probably best to change the
field to text. Thanks for the input, it confirms what I suspected.
 
Stu,
Allen's post is correct. An Option Group can be nulled.
However... I still think that an option group is better suited to
multiple possible value selections, than a boolean T/F selection.
Your call though...
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
Try as I may, I couldn't get both option buttons to clear/uncheck. So maybe
there is some info that I missed passing to you although I suspect my problem
had something to do with the "Yes/No" data type in the table. I've converted
to the "Yes/No" fields to text and I'm one my way. Thank you both for your
comments/assistance.
 
Open the table in design view.
Change the field from Yes/No to Number.

A Yes/No field cannot store the Null value, so it won't work.
If you want to have yes/no/null, you must use a Number field.

There are other good reasons for using Number instead of Yes/No too. If you
want to know:
http://allenbrowne.com/NoYesNo.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.


Stu said:
I tried that and the "No" option was checked. I also tried 999 for the
frame
and then the "Yes" option was checked.

Allen Browne said:
Set the Value of the option group to Null.

Say your Clear button is named cmdClear, and has its On Click property
set
to [Event Procedure]. Click the Button beside this property. Access opens
the code window, and you set up the code like this:

Private Sub cmdClear_Click()
Me.[Frame1] = Null
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.


Stu said:
I have an option group with two option button choices "Yes"
(optionValue =
-1) and "No" (optionValue = 0) bound to a Yes/No field in a table.

If the user clicks a Clear button I want both the Yes and No option
buttons
in the option group to be unchecked. Is there a way to code this or do
I
need to change the table field to type Text?
 
OK Stu,
When the client decides to start designing the application, instead of
you,
there's only one thing to say... "Mo' money... mo' money! :-D
Al Campagna
 
Back
Top