check all checkboxes

rbarrett

New member
Local time
Today, 15:52
Joined
Jun 18, 2001
Messages
8
I am trying to create a button that will check all "checkBox"s on a sub form. I have created a form that has a subform on it, in the subform are checkboxes, the checkboxes are tied to a true/false field in a table. I have the button on the main form. This code may be way off, I am a huge "rookie" when it comes to VBA for Access2000. I am not sure if this code is even the correct one I need. The subform is called "sfrmClose" and the form is called "frmClose". What I am attempting to do here is loop through the sub form and set all the checkboxes to true when the button is clicked. When I try to run the code it comes back with a variable not defined error on the SubForm.Controls line.

Private Sub Check_All_Click()
Dim ckb as CheckBox
For Each ckb In SubForm.Controls
If acCheckBox = False Then
.acCheckBox = True
End If
Next ckb
End Sub
 
Real close

dim ctl as control

for each ctl in me!subName.controls
if ctl.controltype=accheckbox then
if ctl.value=false then
ctl.value=true
endif
endif
next ctl
 
Thank you I am not getting the error anymore but it does not seem to check anymore then the one check box. The subform is pulling a query that lists records and each record has a check box. Is there a way to check all of the boxes that are pulling up?
 
Did you change the subName to the name of your subform?

Is the CheckAll checkbox on your main form?

Are your checkboxes on your subform bound?
 

Users who are viewing this thread

Back
Top Bottom