output report from a query with criteria

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

Guest

hello,

in my database, a table contains a column of date.
and i have built a query in which the user can specify to display the
records within a date range. (for example, if the user chooses 2/15/2006 as
the starting date and 2/28/2006 as the ending date, only the rows containing
a date between these two will be shown in the outputted table)

how do i output a report based on the filtered table?

thanks.
 
You can base your report on the query. A report can have a table, a query,
or a SQL statement as its recordsource.
 
i see.
then how can i do so if i have created a form to serve the same purpose
(similar to the 'Sales by Year Dialog' in the northwind database)?

thanks again.
 
In this case the form is being used to feed the criteria to the query.

The form is unbound and has two textboxes and a command button on it. For
example, say these two textboxes are named txtStartDate and txtEndDate, and
the form is named frmParam. You should set the format of the two textboxes
to Short Date.

In the query you have a Date column where you currently have some criteria
that allow the user to enter the date range. Change that criteria to
Between Forms!frmParam!txtStartDate And Forms!frmParam!txtEndDate

You have a report that is bound to your query. To run the report, open your
form, enter the two dates and hit the command button.

The command button would have
DoCmd.OpenReport "name of report", acPreview
in the code for the On Click event.
 

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

Back
Top