Select All Check Boxes

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a series of subforms within a form (Access 2002) that are part of a
questionnaire. Each subform has a different number of questions.

I would like to give the user the option to select Yes for every question
via a "Select All" button/command.

Please can someone help me write the code or tell me how to do in an Access
form.

Many thanks
 
NMactic said:
I have a series of subforms within a form (Access 2002) that are part of a
questionnaire. Each subform has a different number of questions.

I would like to give the user the option to select Yes for every question
via a "Select All" button/command.

Please can someone help me write the code or tell me how to do in an
Access
form.

Many thanks

Try something like this:

Dim ctl as CheckBox
For Each ctl in Me.Detail.Controls
ctl = -1
Next

HTH - Keith.
www.keithwilby.com
 
NMactic,

To use a checkbox as the the "Select All" control, loop through the form's
Controls collection, and set them to the value of the "Select All" box:

Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acCheckBox Then
ctl = Me![YourSelectAllCheckBox]
End If
Next ctl

Hope that helps.
Sprinks
 
Keith,

If there are any non-checkbox controls in the Detail section, this code will
fail with a Type Mismatch error.

Sprinks
 
Sprinks said:
Keith,

If there are any non-checkbox controls in the Detail section, this code
will
fail with a Type Mismatch error.

D'oh, of couse it will. I was in a bit of a rush yesterday and missed the
'if it's a check box' line. Apologies to the OP.
:-)

Keith.
 
Sprinks

Works perfectly, thank you!

NMactic

Sprinks said:
NMactic,

To use a checkbox as the the "Select All" control, loop through the form's
Controls collection, and set them to the value of the "Select All" box:

Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acCheckBox Then
ctl = Me![YourSelectAllCheckBox]
End If
Next ctl

Hope that helps.
Sprinks


NMactic said:
I have a series of subforms within a form (Access 2002) that are part of a
questionnaire. Each subform has a different number of questions.

I would like to give the user the option to select Yes for every question
via a "Select All" button/command.

Please can someone help me write the code or tell me how to do in an Access
form.

Many thanks
 
Back
Top