Print current record on form

D

Deb Struble

How do I get a report to print the information based on the current record
in a form? For example, the user would enter the record through a form and
then click on a print button on the form. It would then print only the
current record.
Thanks!
 
R

Rick Brandt

Deb said:
How do I get a report to print the information based on the current
record in a form? For example, the user would enter the record
through a form and then click on a print button on the form. It
would then print only the current record.
Thanks!

The OpenReport Method has an optional WHERE argument that can be used to
filter the report before previewing or printing. Basically you need to use
that to apply a filter that mathces the primary key field(s) on the cirrent
record.

Example with a single field key named "ID"...

DoCmd.OpenReport "ReportName", acViewPreview,, "ID = " & Me!ID

In case it's a new record or a record that the user might have edited it is
a good idea to also save the record first.

Me.Dirty = False
DoCmd.OpenReport "ReportName", acViewPreview,, "ID = " & Me!ID
 

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