report to PDF format

S

susan.m.beebe

I have the Lebans solution for sending a report to a pdf file and it
works great. However, I want to send a report for a specific record
only. I have a form with a command button on it that indicates to
print the report but only for the record that I am currently looking
at in the form.

I have looked through the code for the creation of the snapshot, etc.
But don't see anywhere that I would indicate a specific record for
which to print the report. Any suggestions?
 
G

Graham Mandeno

Hi Susan

From memory, Stephen's sample code does not open the report, but simply
executes a DoCmd.OutputTo to create the snapshot file (which then gets
converted to a PDF).

In that case, if the report is already open, with the correct record
filtered, then that is all that will be output.

So, before calling Stephen's procedure, open the report hidden, with the
required WHERE condition, and then close it afterwards:

DoCmd.OpenReport "YourReportName", _
WhereCondition:="RecordID=" & <desired record>, _
WindowMode:=acHidden

<call the PDF procedure as usual>

DoCmd.Close acReport, "YourReportName"
 
T

tina

if the report will only be used in a single-record capacity, you can write
the criteria in the report's RecordSource - query or SQL statement. the
criteria syntax would be

WHERE FieldName = Forms!FormName!PrimaryKeyFieldName

replace the fieldname, formname, and primary key fieldname with the correct
names in your database, of course. then you can call the
"ConvertReportToPDF" procedure as usual - you'll get the one record that is
returned by the report's RecordSource.

hth
 
T

Tony Toews [MVP]

I have the Lebans solution for sending a report to a pdf file and it
works great. However, I want to send a report for a specific record
only. I have a form with a command button on it that indicates to
print the report but only for the record that I am currently looking
at in the form.

For a page on how to print a report for a single record and how to
generate reports to attach to emails see the Emailing reports as
attachments from Microsoft Access page at
http://www.granite.ab.ca/access/email/reportsasattachments.htm

Tony
 

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