Check box filter value

G

Guest

I am trying to filter a report (based on a qry) through a form. They do want
the one option I wanted to take out. In the report, there is a check box
field. On the form I had added a check box to filter this section or not.
What I want to happen is this: If they check the box on the form, I want the
report to show only those records whos check boxes are indeed checked. If
the check box on the form is Not checked, then I want no filter whatsoever
and for the report to show all records.
I have multiple other filters on this form as well. All of them now work
successfully, thanks to help from here. (a million thanks already)
I have tried many different statements and different types of criteria from
yes/no; true/false; 0, -1. Nothing seems to make it want to filter and
unfilter. I changed it in the table as well, from yes/no, to true/false and
nothing. The farthest I can get is a Type Mismatch Error. I've dim'd the
statment as a string, varient, boolean, integer. Still nothin. I tried
setting it up as just an On/Off filter also but I think I'm not quite good at
that yet.

Somebody please let me know how to create an On/Off filter for this little
check box. I would be greatly indebted!!!! =)
 
M

Marshall Barton

Pixie78 said:
I am trying to filter a report (based on a qry) through a form. They do want
the one option I wanted to take out. In the report, there is a check box
field. On the form I had added a check box to filter this section or not.
What I want to happen is this: If they check the box on the form, I want the
report to show only those records whos check boxes are indeed checked. If
the check box on the form is Not checked, then I want no filter whatsoever
and for the report to show all records.
I have multiple other filters on this form as well. All of them now work
successfully, thanks to help from here. (a million thanks already)
I have tried many different statements and different types of criteria from
yes/no; true/false; 0, -1. Nothing seems to make it want to filter and
unfilter. I changed it in the table as well, from yes/no, to true/false and
nothing. The farthest I can get is a Type Mismatch Error. I've dim'd the
statment as a string, varient, boolean, integer. Still nothin. I tried
setting it up as just an On/Off filter also but I think I'm not quite good at
that yet.

Somebody please let me know how to create an On/Off filter for this little
check box. I would be greatly indebted!!!! =)


How is the report filtered? The usual way is for the form
to use the OpenReport method's WhereCondition argument.
However, you might be using criteria in the report's record
source.

In the former case, you would set the filter string using
code like:

If Me.checkbox = True Then
strFilter = strFIlter & " AND yesnofield = True "
End If

If you are using criteria in the query, then set the
yesnofield's criteria to:
True
and the Or line below that to:
Forms!theform.checkbox=False
 
G

Guest

And it's that easy.....

Yes the report is filtered by strFilter in the open report. I actually
tested both methods you gave and both worked great. However, I'm not a fan
of having criteria in the query, especially if everything else is in code.
It always seems to get messed up for me eventually.
My problem with trying that code previously is I thought I had to have some
kind of
"Else" to go along with it and couldn't think for the life of me how to say
'Else, show all records'! Also I was trying to make it more complicated than
just saying how you put it. So a gazillion thanks for making that soooo
simple!!!!!! My form and report are now fully complete!!!!

=)
 

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