Access 2003 - changing query criteria

P

Pat

I have a report (based on a query) set up to generate an RTF. If I want to
generate a "report" or "rtf" for a single record I have to go to the query
and change the criteria to the specific record otherwise I get all table
records. I tried setting up a form to search for a particular record, but
still get all records when the report is generated. Is there a way I can use
a form interface so another can select a specific record (criteria) without
having to go into the query?
 
A

Al Campagna

Pat,
In the query behind your report you should have one key field that identifies a unique
record.
For example, a CustomerID, or EmployeeID, or InvoiceNo.. etc...

While the form is open, and on a particular record... say Customer records with a
CustID. Use that form value to filter the query for the report, by applying this criteria
to the CustID column...
=Forms!frmYourFormName!CustID
Now the report will be limited to the one record where the CustID = the value currently
displayed on the form.

Or, with a button on the form called (ex.) Print This Customer, use the Where argument
to open the report for only one that CustID value for the record you are on.
DoCmd.OpenReport "rptYourReportName", acViewPreview, , "CustID = " & CustID

Along with another buttton named Print All Customers... with no Where argument
DoCmd.OpenReport "rptYourReportName", acViewPreview

... would allow you to use the exact same report two ways. (Print 1, Print All)

--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

"Find a job that you love, and you'll never work a day in your life."
 

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