showing report based on selected record?????

rich_bell20

Registered User.
Local time
Today, 17:04
Joined
May 6, 2003
Messages
31
hi, does anyone know how to show a report based on 1 record selected. eg, a bill for 1 customer only, if im viewing a customers details and payment due data, is there anyway to show just that 1, instead of a list of all the customers and payments??
 
There are a couple ways to do this. I assume you're looking at data on a form and already have a report formatted. You just want the current record to be printed to your report.

Use the DoCmd.OpenReport method. The first parameter is the name of the report. The second is the view. The third is the filtername, which can be the name of a saved query or some other filter. The fourth is a "where" condition - which if you know SQL is particularly useful and flexible.

Using the 3rd parameter, you can create a saved query that pulls parameters from your form using expressions like this: [Forms]![frmMain]![EmployeeID]
so that when the report is called, it will look for the query and the query will look for data on the form.

Or, if you are using a filter in your form to view particular records, you can just execute this code from an event on your form:
DoCmd.OpenReport reportname, acviewpreview, Me.Filter

Using the fourth parameter with the where condition is the most flexible but also most confusing for the unitiated.
 
re:

Thanks for the quick reply, but is there any chance you could explain further, im only just learning and i'm finding it difficult to understand, i've inlcuding a copy of my database if you would be so kind to look at it, i want to disply the information shown in the form (frminvoice) for each customer/order. cheers!
 

Attachments

I assume you'd like to call the report from frmInvoice? Kind of hard to test the system since there's only one order in the entire database!
 
re:

hi, i was told to put this into the criteria of 'orderID' in the report query, ([frmInvoice]![OrderID]). it works when i select the form, but it asks me for a parameter, if i type 2, it goes to order 2 etc, am i missing anything out???
thanks
 

Users who are viewing this thread

Back
Top Bottom