By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,478 Members | 1,501 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,478 IT Pros & Developers. It's quick & easy.

REQ: Help with querying check-boxes

P: n/a
dad
I am building a database to track the maintenance records on a fleet
of cars. I need to run a report on that will display data based on
whether a box is checked or not (i.e. all cars that have the oil
change box checked, or a report that shows all cars and lists all the
boxes that each have checked (for a list of maintennace due). Anyone
out there have any advice? Any would be appreciated. Thanks in
advance!
Mar 4 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Are you asking how to create a report based upon a query or how to do
the query in the first place?

Mar 4 '06 #2

P: n/a
If you are asking how to create the query (which I think you are),
perhaps the simplest way to go about this would be to select create a
new query, then use the simple query wizard which whill allow you to
select which table or query contains the records you are interested in.
It will then allow you to select the relevant fields to include in
your query. Be certain to include your check box fields. Next it will
ask you to name the query and gives you the option to modify the query
design, select this option.

You will then see a list of your fields. Find your check box fields
and in the corresponding row labeled "Criteria" In this row type "=
false" if you want the records that aren't checked or "= true" if you
want the records that are checked.

Save the query. Then you can use the report wizard to help you create
a nice looking report based upon this query.
I hope that helps.

Jody Blau

Mar 4 '06 #3

P: n/a
dad wrote:
I am building a database to track the maintenance records on a fleet
of cars. I need to run a report on that will display data based on
whether a box is checked or not (i.e. all cars that have the oil
change box checked, or a report that shows all cars and lists all the
boxes that each have checked (for a list of maintennace due). Anyone
out there have any advice? Any would be appreciated. Thanks in
advance!


When you open a report you can tell the report what you want to filter.
DoCmd.OpenReport "ReportName", , , "WhereClauseFilter"

In your case, most likely you call the report from a form. Let's call
the form RptFilter. Here you could present what you want to filter

Using your above example, you could have 2 lines; description & 2
checkboxes.

FilterField Filter? Yes/No?
Oil Change OCF Val1
Maint Due MDF Val2

The filter names are OCF/MDF as checkboxes. Val is a checkbox. Now if
you have a command button to print the report, first create a filter,
then call report

Dim strFilter As String
If Me.OCF Then strFilter = "OilChange = " & Me.Val1 & " And "
If Me.MDF Then strFilter = strFilter & _
"Maint Due = " & Me.Val2 & " And "
'remove And
If strFilter > "" Then strFilter = Left(strFilter,Len(strFilter)-5)
DoCmd.OpenReport "ReportName", , , strFilter

This will open the report and filter as necessary.

I wouldn't bother filtering the report's recordsource SQL, do it from
the Where clause filter. This way you remain flexible.

I sometimes create a field to store a description of the filter.
Dim str As String
If Me.OCF Then str = "OilChange " & IIF(Me.Val1,"Y","N") & space(4)
If Me.MDF Then str = str & ""Maint Due " & IIF(Me.Val1,"Y","N")
Me.FilterStr = str

Now when I call the report, in the report header I have a field to
present the filter string. Let's say the form name is Rpt. The control
source of the text box to present the filter would be
="Filtered As " & Forms!Rpt!FilterStr

That way the user knows, if he looks at the report later, what the
report was filtered on.




Mar 4 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.