Check Boxes

M

Mo

I've a form with a number of check boxes on it in pairs.

I'd like only one of each pair of check boxes be selectable at a time,
i.e. if you select one, the other one in the pair is deselected.

I've tried to code this by using the the '.value' property of the check
box to no avail.

Does anyone have an idea if this can be done?

TIA,

Mo
 
D

Douglas J Steele

Realistically, this is a variance from the Windows standard: checkboxes are
intended to indicate multiple selections are possible, radio buttons are
intended to indicate only a single choice may be made. Using option groups
should help.

If you want to continue with what you have, you should be able to put code
in both checkbox's AfterUpdate event along the lines of:

Private Sub chkOption1_AfterUpdate()

Me.chkOption2 = Not Me.chkOption1

End If


Private Sub chkOption2_AfterUpdate()

Me.chkOption1 = Not Me.chkOption2

End If
 
J

Jeff Boyce

I'm confused. If you are saying that you want to disable checkbox2 if
checkbox 1 is selected, how would you then subsequently select checkbox2
(say, if you made a mistake in picking checkbox1)?

Another approach might be pairs of radio buttons -- with these controls, you
could pick only one or the other in each (paired) group.
 
P

Peter Danes

Hi Mo,

Check boxes can be forced to act that way, the option group control wizard
will help you create them that way from scratch.

Or you can put option groups on the form and transfer the existing check box
pairs into the group. One option group must be created for each pair and you
can't just drag them in, you must cut them from the form and paste them into
the option group. You then give each check box in the group a different
value (on the data tab of the properties box}.

Or you can manually attach event code to each check box that will turn off
its partner. That's tedious and generally useful only if you need other,
very specific things to happen, like some check boxes turn off all others in
the group and some do not.

But aside from all that, check boxes are not really intended to act that
way. They are supposed to be used for individual options that can be turned
on or off independent of each other, and the standards for graphic
interfaces have educated users to expect controls with a certain look to act
in a certain way. Going against this standard is rarely a good idea, unless
you like confused users.

What you want are radio buttons, or maybe toggle buttons. (Even a single
toggle button can be used to turn an option on or off. Some people don't
like them, but I've occasionally found them quite useful.) I would recommend
that you change your check boxes to radio buttons using the Format / Change
To / Radio Button menu, then proceed. All the above instructions apply to
radio buttons as well.

--

Pete

This e-mail address is fake to keep spammers and their auto-harvesters out
of my hair. If you need to get in touch personally, I am 'pdanes' and I use
Yahoo mail. But please use the newsgroups whenever possible, so that all may
benefit from the exchange of ideas.
 
M

Mo

Thanks to all for their replies to my query.

I'll certainly try and take some of your suggestions on board.

Mo
 
J

Jeff Boyce

Confused AND hyper-caffeind-nated!

(I'll stick with the notion of option buttons, though...)

Jeff Boyce
<Office/Access MVP>
 

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