Radio button problem

C

creiner1

I have a subform with multiple radio button option groups. Each
option group has two options. When any of the buttons on the subform
is clicked, ALL of the options groups are immediately filled in as
well. It does not seem to matter which option is selected. For
example, I can select option 1 in group 1, and option 2 will
immediately become selected in groups 2-5.

Anyone have a solution for this?
 
S

Steve Schapel

Creiner,

This would indicate that the Option Groups are all bound to the same
field in the form's underlying table/query. Look at the Properties of
each Option Group, in particular the Control Source property, and you
will probably see the cause of the problem. The solution will depend on
what these Option Groups are actually supposed to do, and what data they
are supposed to relate to.
 
C

creiner1

Thanks for the prompt reply, Steve. I wish the solution was as
obvious as you suggest, but each option group is bound to a different
field in the same table. Could the option groups have been grouped
together in some way? I'm not aware of any way that this could happen.
 
A

Armen Stein

I have a subform with multiple radio button option groups. Each
option group has two options. When any of the buttons on the subform
is clicked, ALL of the options groups are immediately filled in as
well. It does not seem to matter which option is selected. For
example, I can select option 1 in group 1, and option 2 will
immediately become selected in groups 2-5.


Is it possible that although your option groups are laid out as
different controls, they are in fact bound to the same field in your
recordsource? This could lead to the behavior you are describing.

Armen Stein
Microsoft Access MVP
www.JStreetTech.com
 
S

Steve Schapel

Creiner,

The only other explanation I can think of is if there is code or macros
running that update the value of controls based on the entry of the
others. But this seems very unlikely, without you knowing about it!
Still, I suppose you need to have a look at the event properties of the
option groups, and see what's there.

I take it this applies to existing records, as well as new ones?
 
C

creiner1

Is it possible that although your option groups are laid out as
different controls, they are in fact bound to the same field in your
recordsource? This could lead to the behavior you are describing.

Armen Stein
Microsoft Access MVPwww.JStreetTech.com

Each option group has a different control source. The data gets
entered into the tables fine. After selecting any option on the form,
all the other option groups are set to the option corresponding to a
value of 0. After this first selection is made, all of the option
groups can be set independently from each other. It's only on the
first click that they all get erroneously selected.

Interestingly enough, this problem only seems to arise for option
groups for which there are only two possibly choices. Option groups
with 3 or more choices remain blank when an option is selected.
 
C

creiner1

I take it this applies to existing records, as well as new ones?

This actually only applies to new records. I should have mentioned
that the problem only happens the first time a selection is made.
After that, the form functions perfectly fine. Basically, the first
time you click any of the options it sets all the option groups to 0.
It is then possible to make selections for individual option groups.
 
S

Steve Schapel

Creiner,

It is unusual to have the Option Value of one of the Option Buttons in
an Option Group (does that give you enough options :) ) to be 0.
Nothing wrong with it, really, just unusual. I think this problem is
related to the Default Value property, either of the Option Groups on
the form, or of the corresponding fields in the underlying table, which
I would assume is set to 0.
 
C

creiner1

Creiner,

It is unusual to have the Option Value of one of the Option Buttons in
an Option Group (does that give you enough options :) ) to be 0.
Nothing wrong with it, really, just unusual. I think this problem is
related to the Default Value property, either of the Option Groups on
the form, or of the corresponding fields in the underlying table, which
I would assume is set to 0.

The default value was my first thought as well. I checked it and the
defaults are blank (not 0, but blank) for the option groups and the
underlying fields. These fields happen to be yes/no values despite
being displayed in option groups with radio buttons on the form (this
was a requirement made by the client). Perhaps a blank default value
won't work, and it switches a blank value to a false value after the
form is updated when the user selects the first option?
 
S

Steve Schapel

Creinier,

Yes, I think you have found an explanation. As soon as the new record
is started, the Yes/No field needs a value. Since a Yes/No field can't
be Null, it is assuming the value No (0) until such time as you tell it
otherwise.

I think it will solve the problem, from a UI point of view, if you set
the Default Value of the option groups on the form to another number,
for example 1 (assuming you have used -1 for the Option Value of the
'Yes' Option Button). But, since in Access the value of Yes for a
Yes/No field is "any integer other than 0", if the user does not select
one of the option buttons in any given option group, the programme will
treat it as Yes/True.
 
A

Armen Stein

Yes, I think you have found an explanation. As soon as the new record
is started, the Yes/No field needs a value. Since a Yes/No field can't
be Null, it is assuming the value No (0) until such time as you tell it
otherwise.

I think it will solve the problem, from a UI point of view, if you set
the Default Value of the option groups on the form to another number,
for example 1 (assuming you have used -1 for the Option Value of the
'Yes' Option Button). But, since in Access the value of Yes for a
Yes/No field is "any integer other than 0", if the user does not select
one of the option buttons in any given option group, the programme will
treat it as Yes/True.

I agree, this seems to be the answer.

If you do want a Null default, you can change the underlying field to
Number-Integer instead of Yes/No. Now your fields can default to
Null, and can still be set to True (-1 in Access) or False (0). You'll
need to decide whether a user can set the value back to Null after
they've selected either True or False - that would require another
Option.

In our projects, when we needed to distinguish between Yes, No and
Null, we used a combobox with Yes, No and blank as the three values in
the rowsource.

See also: the Triple State property of a checkbox, although the
"gray" value of the checkbox when it's Null can be confusing to the
user.

Armen Stein
Microsoft Access MVP
www.JStreetTech.com
 

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