Filtering and Printing a Report based on Current Form

  • Thread starter Thread starter Keith
  • Start date Start date
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
 
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] & "'"
 
Back
Top