Uncheck checkbox

M

Marc

Hello,

I have a form with 6 check boxes. Box1 has a default of True. If ANY other
boxes are checked, I would like to automatically uncheck box1. Can you tell
me the best way to do this?

Thanks,
 
M

Maurice

If you use seperate checkboxes you have to check every box when clicked on.
Fortunately the code is same for every checkbox:

me.checkbox1=not me.checkbox2
me.checkbox1=not me.checkbox3

etc.

put the code in the onclick event of the checkbox.
If you are working on a form and want to do the action as a final check you
could loop through the checkboxes and set checkbox based on the the values
of the other checkboxes.

hth
 
M

Marc

Thanks Maurice,

I'm afraid I didn't explain myself very well. Box1 is the only check box I
want this to happen to. The other 5 can be checked in any combination...If I
check box2, box1 gets unchecked, if I check box3, box1 gets unchecked, if
multiple boxes are checked, box1 should be unchecked, etc. Boxes 2-6 can be
all checked, or any combination.

Thanks,
 
M

Maurice

Hi Marc,

I misread sorry for that. In the on click of the checkboxes just put:

me.checkbox1=false

This will make checkbox 1 be unchecked based on the choices you make (also
the combinations eg 2 and 5 are checked)

hth
 
K

Klatuu

Put this function in your form's module and change the names to the actual
names of your check boxes.

Private Sub CheckTheBoxes()
With Me
If .Check10 + .Check2 + .Check4 + .Check6 + .Check8 <> 0 Then
.Check0 = False
Else
.Check0 = True
End If
End With

End Sub

Call it in the After Update event of each of the checboxes

Private Sub Check10_AfterUpdate()
Call CheckTheBoxes
End Sub
 

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