Option Group - Clear Yes/No

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?
 
A

Allen Browne

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
 
A

Al Campagna

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."
 
S

Stu

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?
 
S

Stu

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.
 
A

Al Campagna

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."
 
S

Stu

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.
 
A

Allen Browne

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?
 
A

Al Campagna

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
 

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

Similar Threads


Top