Filtering and Printing a Report based on Current Form

K

Keith

Hi There

Is it possible (I'm sure it is, but is it easy!), to send the contents of
the current record (open on a form) to print using a particular report?

I can obviously get it to print the desired report, but unless I filter my
form first, I get all records printing on my report.

What I want to do is use an unfiltered form, and just print the current
record of it - filtering at run-time I guess.

Regards

Keith
 
R

Rick Brandt

Keith said:
Hi There

Is it possible (I'm sure it is, but is it easy!), to send the contents of
the current record (open on a form) to print using a particular report?

I can obviously get it to print the desired report, but unless I filter my
form first, I get all records printing on my report.

What I want to do is use an unfiltered form, and just print the current
record of it - filtering at run-time I guess.

This is possibly the single most common way that reports are used.

The OpenReport Command has an optional argument for supplying a WHERE clause (without
the word "where"). You simply use that clause to filter the report to the matching
value on the current form (usually the Primary Key).

DoCmd.OpenReport "SomeReport",,,"[PKField] = " & Me![PKField]

The above is the syntax if [PKField] is numeric. For a text field you would need to
add quote delimiters.

DoCmd.OpenReport "SomeReport",,,"[PKField] = '" & Me![PKField] & "'"
 

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