Select All Check Boxes

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
 
K

Keith Wilby

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
 
G

Guest

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
 
G

Guest

Keith,

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

Sprinks
 
K

Keith Wilby

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.
 
G

Guest

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
 

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