Mutually Exclusive Check Boxes

C

charles.kendricks

I have a form that allows the user to choose between several times of
day represented by check boxes. Two of those times of day I want to be
mutually exclusive, so that if one is set to True (checked), the other
is automatically, and immediately set to False. I thought that a
simple IF statement would do the trick but it doesn't seem to work:

If Waking.Value = True Then
Morning.Value = False
ElseIf Morning.Value = True Then
Waking.Value = False
End If

My thinking is that perhaps the On_Current event for the form is not
the right place to put the code, am I at least on the right track?
 
G

Graham R Seach

Charles,

You don't need to code for it. Just place the mutually exclusive checkboxes
into an Option Group.

Regards,
Graham R Seach
Microsoft Access MVP
Canberra, Australia
 
R

Rick Brandt

I have a form that allows the user to choose between several times of
day represented by check boxes. Two of those times of day I want to be
mutually exclusive, so that if one is set to True (checked), the other
is automatically, and immediately set to False. I thought that a
simple IF statement would do the trick but it doesn't seem to work:

If Waking.Value = True Then
Morning.Value = False
ElseIf Morning.Value = True Then
Waking.Value = False
End If

My thinking is that perhaps the On_Current event for the form is not
the right place to put the code, am I at least on the right track?

If those choices are mutually exclusive you should use one field in your table
instead of two and then use an OptionGroup frame with two RadioButtons within.
That will handle the exclusive part for you.
 

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