Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

too many checkboxes 1

Status
Not open for further replies.

jvonbokel

Programmer
Sep 13, 2002
3
US
I have a form with 28 checkboxes, all of which correspond to fields in a query. I have a button which I want to have pull up a report, but only show records with matching checks. For example, if a user clicks 2 checkboxes and hits the button, I want them to see all records that have those two checkboxes checked, including records that also have other checkboxes checked. Here's what I have in the code for the button so far:

DoCmd.OpenReport &quot;ReportName&quot;, acPreview, , &quot;ChkBox1 <= [Forms]![FormName]![Field1] and ChkBox2 <= [Forms]![FormName]![Field2] and etc.

This works fine for one form with a half-dozen checkboxes, but the problem with this one is, by the time I type that out for 28 checkboxes, I apparently run out of room on that line. Any suggestions?

Thanks
 
You can append the statement onto more than one lines. All you've got to do is the following:

DoCmd.OpenReport &quot;ReportName&quot;, acPreview, , ChkBox1 <= [Forms]![FormName]![Field1] And ChkBox2 <= [Forms]![FormName]![Field2] And _
ChkBox3 <= [Forms]![FormName]![Field3] And ChkBox4 <= [Forms]![FormName]![Field4] etc, etc
 
Aha, that's simple enough. Thanks! By the way, for the record, the part I wanted to split up was inside quotes, so I had to do something like this:

DoCmd.OpenReport &quot;ReportName&quot;, acPreview, , &quot;ChkBox1 <= [Forms]![FormName]![Field1] And &quot; _
+ &quot;ChkBox2 <= [Forms]![FormName]![Field2] And &quot; _
+ &quot;ChkBox3 <= [Forms]![FormName]![Field3] And &quot; _
etc, etc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top