getting query results to a report

R

Ryan Young

Sorry for the dumb question, but I seem to be overlooking something. I am
trying to get the results of a query to display in a report. The problem is
that only the results of the initial query are shown in the report, not any
changes in the query. For example, I want to query by date (by changing the
criteria) and have the results show in a report (created using the wizard,
grouping by date field). Currently, my report is showing all dates, not the
results of the query.
 
R

Ryan Young

Actually to further that and not sound like a complete idiot, my
understanding is that every time the report is run from the reports screen,
the data is retrieved from the query - not stored in the report - which
means in my mind that it should report the results of the query.
 
J

Jerry Porter

Ryan,

When you say "initial query" and "changes to the query", what do you
mean? When you change the criteria, do you save the query? Is the query
selected as the RecordSource of the report? If so, the report should
reflect what's in the query.

If you're using different date criteria on a regular basis, there are
better ways than modifying the query. This would involve using a
parameter query to either prompt the user for the date, or read the
date from a form.

Jerry
 
R

Ryan Young

OK, I'll try to clarify things a bit:

I've created a query based on a table. Then I've created a report based on
this query. When I apply criteria to the query, the results of the criteria
are bit displayed in the report. If I create a new report, the results are
accurately reflected in it.

I guess what I need to do is figure out how to do the parameter query so I
can query a specific date or range. This can be done right in the report?
 
J

John Vinson

I guess what I need to do is figure out how to do the parameter query so I
can query a specific date or range. This can be done right in the report?

No. It's done right *in the Query*.

Instead of putting a literal criterion on the Criteria line in the
query grid, type a prompt in [square brackets], such as

BETWEEN [Enter start date:] AND [Enter end date:]

These are called Parameters; when you open the Report, two dialog
boxes will pop up in succession, asking you to (of course) Enter start
date: and Enter end date:

When you type dates in response, the report will open with those dates
as its criteria.

This works with any datatype, text, number, date...

You can also use an unbound Form to supply criteria; if you have a
form named frmCrit with textbox txtLast labeled "Enter start of last
name:", combo box cboDepartment labeled "Select department", with a
DepartmentID as its bound column, and a checkbox chkExempt labeled
"Check yes for exempt employees", you could have criteria

LIKE [Forms]![frmCrit]![txtLast] & "*"

on the LastName field,

= [Forms]![frmCrit]![cboDepartmentID]

on the DepartmentID field, and

= [Forms]![frmCrit]![chkExempt] on the yes/no field Exempt.

John W. Vinson[MVP]
 
Top