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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checkbox query syntax

Status
Not open for further replies.

cutestuff

Technical User
Sep 7, 2006
162
CA
I can't seem to get the following to work:

Like IIf(([Forms]![frmPR]![chkA])=True,"A","*") Or Like IIf(([Forms]![frmPR]![chkB])=True,"B","*") Or Like IIf(([Forms]![frmPR]![chkC])=True,"C","*") Or Like IIf(([Forms]![frmPR]![chkD)=True,"D","*")

frmPR has 4 checkboxes that the user can select (one or more). I would like it to filter the results based on what the user checks - whether it be just A, or A and B, etc. I also need it to display ALL records if the user does not check anything. I was able to get it to filter based on the checkboxes but it wouldn't display all if no checkboxes are selected. Or I was able to display all but it wouldn't filter properly. :(
What am i doing wrong?

TIA,
j
 
SELECT ...
FROM ...
WHERE (yourField='A' AND [Forms]![frmPR]![chkA]=True)
OR (yourField='B' AND [Forms]![frmPR]![chkB]=True)
OR (yourField='C' AND [Forms]![frmPR]![chkC]=True)
OR (yourField='D' AND [Forms]![frmPR]![chkD]=True)
OR ([Forms]![frmPR]![chkA] OR [Forms]![frmPR]![chkB] OR [Forms]![frmPR]![chkC] OR [Forms]![frmPR]![chkD])=False

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top