Help with a query

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

Guest

Hello,

I have 4 check boxes in my queary, and if none of the check boxes have been
check I dont want the record displayed. If any of them have been checked
then it should be listed. If anyone could help me with this.

Thank You
 
In the design view grid enter -1 (minus one) under the field of the first
checkbox in the criteria row. Then drop down a row and enter -1 for the
second checkbox. Do the same for the rest - each on a different row.

Using a different row make it an OR function.
 
SELECT CheckBoxes.*
FROM CheckBoxes
WHERE ([YesNo1]+[YesNo2]+[YesNo3]+[YesNo4])<>0 ;

Yes/No fields actually store a -1 for Yes and a 0 for No. Strange but true.
If you add them all up and it doesn't equal 0 at least one is checked.

Put in the actual table name for CheckBoxes and the checkbox names in the
YesNo's.
 
Hello,

I have 4 check boxes in my queary, and if none of the check boxes have been
check I dont want the record displayed. If any of them have been checked
then it should be listed. If anyone could help me with this.

Thank You
Try this:

SELECT MyTable.Record_nbr,
MyTable.Record_name,
MyTable.CkBox1,
MyTable.CkBox2,
MyTable.CkBox3,
MyTable.CkBox4
FROM MyTable
WHERE (IIF(CkBox1 = -1,1,0)
+ IIF(CkBox2 = -1,1,0)
+ IIF(CkBox3 = -1,1,0)
+ IIF(CkBox4 = -1,1,0)) > 0;

Change names to agree with your table names.
 
Back
Top