I’d like to be able to use a form to select query criteria for a series of check boxes. There are 12 boxes which creates, I believe, 105 difference on/off combinations for the buttons. There’s got to be an easy way to do this…I hope?
E
![]() |
There are isolated problems with current patches, but they are well-known and documented on this site. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » form based query chk boxes (A2000)
Create a form with 14 – or however many you need – unbound check boxes, i.e. their control source is blank.
Set their Triple State property to Yes. You can do this for all check boxes at once, if you like.
Give them meaningful names, for example chkAdvocates, chkBoard, …, chkBlank7.
Let’s say that the form is named frmCriteria.
Create a query based on your table, or on an already existing query.
Add the fields you need, for example to display them in a form or report, to the query grid.
Next, add a column [Forms]![frmCriteria]![chkAdvocates]
.
Clear the Show check box for this column.
In the Criteria row, enter [ysnAdvocates] Or Is Null
Repeat for the other 13 or so check boxes and the corresponding yes/no fields.
Now, open the form, and tick or clear some of the check boxes.
Then, switch the query to datasheet view to check that the correct records are returned.
Note: check boxes in the neutral (grayed) state will not impose a restriction.
Create an After Update event procedure for the check box associated with ysnNwltr to set all other check boxes to Null (gray) if it is ticked. If the 14 (or whatever) check boxes are the only ones on the form, you can use a loop instead of enumerating the individual check boxes. In the following, chkNwltr is the name of the check box.
Private Sub chkNwltr_AfterUpdate()
Dim ctl As Control
If Me.chkNwltr = True Then
For Each ctl In Me.Controls
If ctl.ControlType = acCheckBox And Not ctl.Name = “chkNwltr” Then
ctl = Null
End If
Next ctl
End If
Set ctl = Nothing
End Sub
Create an After Update event procedure for the check box associated with ysnNwltr to set all other check boxes to Null (gray) if it is ticked. If the 14 (or whatever) check boxes are the only ones on the form, you can use a loop instead of enumerating the individual check boxes. In the following, chkNwltr is the name of the check box.
Private Sub chkNwltr_AfterUpdate()
Dim ctl As Control
If Me.chkNwltr = True Then
For Each ctl In Me.Controls
If ctl.ControlType = acCheckBox And Not ctl.Name = “chkNwltr” Then
ctl = Null
End If
Next ctl
End If
Set ctl = Nothing
End Sub
Create a form with 14 – or however many you need – unbound check boxes, i.e. their control source is blank.
Set their Triple State property to Yes. You can do this for all check boxes at once, if you like.
Give them meaningful names, for example chkAdvocates, chkBoard, …, chkBlank7.
Let’s say that the form is named frmCriteria.
Create a query based on your table, or on an already existing query.
Add the fields you need, for example to display them in a form or report, to the query grid.
Next, add a column [Forms]![frmCriteria]![chkAdvocates]
.
Clear the Show check box for this column.
In the Criteria row, enter [ysnAdvocates] Or Is Null
Repeat for the other 13 or so check boxes and the corresponding yes/no fields.
Now, open the form, and tick or clear some of the check boxes.
Then, switch the query to datasheet view to check that the correct records are returned.
Note: check boxes in the neutral (grayed) state will not impose a restriction.
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.
Notifications