Check Box

M

M.A.Halim

Hi All
I have a Qry with one CheckBox column "True" or "False" .
Now I have a form with one checkBox if this box is checked I want the Qry to
show all the True Records if not checked I want the Qry to return all records.
in the Qry Grid I used this expression
IIF(IsNull([Forms]![MyForm]![CheckBoxName]),"*","True"). but this didn't
work... When I used the simple one [Forms]![MyForm]![CheckBoxName] the qry
returns the Records with true Values if the box is checked and the Records
with False Values if unchecked.
Any Help
Thanks for your non Stop support.
 
A

Allen Browne

You can't easily enter this in the Criteria row in query design.
Switch the query to SQL View.
Locate the WHERE clause, and edit it like this:

WHERE (([Forms]![MyForm]![CheckBoxName] = False)
OR ([SomeField] = True))

This works because the WHERE clause is ultimately something that evalutes to
true or false (or null) for each record. If it's True, that record gets
included; otherwise it's rejected. The WHERE clause above is *always* true
if the check box is unchecked (false.) If the check box is not false, then
the expression is only true where the field is true.
 
J

Jerry Whittle

If using a Yes/No field don't put quotation marks around True or False.
Better yet use -1 for True and 0 for False.

Also a Yes/No box is usually not null. If it is, it will show as gray. If
it's white, it's No.

Assuming that there are no nulls, the following should work in the criteria
of the field.

<[Forms]![MyForm]![CheckBoxName] + 1
 
F

fredg

Hi All
I have a Qry with one CheckBox column "True" or "False" .
Now I have a form with one checkBox if this box is checked I want the Qry to
show all the True Records if not checked I want the Qry to return all records.
in the Qry Grid I used this expression
IIF(IsNull([Forms]![MyForm]![CheckBoxName]),"*","True"). but this didn't
work... When I used the simple one [Forms]![MyForm]![CheckBoxName] the qry
returns the Records with true Values if the box is checked and the Records
with False Values if unchecked.
Any Help
Thanks for your non Stop support.

Like IIf([forms]![MyForm]![CheckBoxName]=True,-1,"*")
 
M

M.A.Halim

Thanks a lot, it worked very well.
I appreciate your help
Cheers

--
M.A.Halim
(e-mail address removed)


Allen Browne said:
You can't easily enter this in the Criteria row in query design.
Switch the query to SQL View.
Locate the WHERE clause, and edit it like this:

WHERE (([Forms]![MyForm]![CheckBoxName] = False)
OR ([SomeField] = True))

This works because the WHERE clause is ultimately something that evalutes to
true or false (or null) for each record. If it's True, that record gets
included; otherwise it's rejected. The WHERE clause above is *always* true
if the check box is unchecked (false.) If the check box is not false, then
the expression is only true where the field is true.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

M.A.Halim said:
Hi All
I have a Qry with one CheckBox column "True" or "False" .
Now I have a form with one checkBox if this box is checked I want the Qry
to
show all the True Records if not checked I want the Qry to return all
records.
in the Qry Grid I used this expression
IIF(IsNull([Forms]![MyForm]![CheckBoxName]),"*","True"). but this didn't
work... When I used the simple one [Forms]![MyForm]![CheckBoxName] the qry
returns the Records with true Values if the box is checked and the Records
with False Values if unchecked.
Any Help
Thanks for your non Stop support.
 

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