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?
 
A

Albert D. Kallal

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?

Simply open the report BEFORE you call the pdf routine.

So, for example to send the one recrod to the report we go:

dim strWhere as string
dim strReport as string


strWhere = "CustomerID = " & me!CustomerID
strReport = "CustomerBilling"

docmd.OpenReport strReport,acViewPreview,,strWhere
Call ConvertReportToPDF(strReport, , "c:\r.pdf", False, False)
docmd.Close acReport,strReport

Just don't forget to close the report.....

You can also perhaps throw in a visible = false like:

docmd.OpenReport strReport,acViewPreview,,strWhere
reports(strReport).Visible = false
Call ConvertReportToPDF(strReport, , "c:\r.pdf", False, False)
docmd.Close acReport,strReport

So, just open the report with a "where" clause to restrict the reocrds, even
to the one reocrd you are viewing. So, the final code looks like:

dim strWhere as string
dim strReport as string


strWhere = "CustomerID = " & me!CustomerID
strReport = "CustomerBilling"

if me.Dirty = true then me.dirty = false
docmd.OpenReport strReport,acViewPreview,,strWhere
Call ConvertReportToPDF(strReport, , "c:\r.pdf", False, False)
docmd.Close acReport,strReport

Note also added code in the above to "force" a disk write, since you must
do this if the forms data been modifed to show up on the report....
 
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.

I have looked through the code for the creation of the snapshot, etc.

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
 
D

David W. Fenton

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

You know, I just spoke with a new client today, and they need to
convert Word documents to PDF programattically and attach them to
emails. I didn't realize Stephen's solution depended on the snapshot
viewer, which by definiation must use an Access report as its data
source.

One *can* embed a Word document in a report (I'm pretty sure), but
multi-page documents are not going to print well.

My main problem with the PDF printers is that the user has to supply
the filename (or, at least, confirm it), and in this case, that's
not going to be convenient.

Any suggestions?
 
T

Tony Toews [MVP]

David W. Fenton said:
Any suggestions?

At least one of the open source PDF printing utilities allows you to
create code against it.

Install the open source software PDFCreator. (Watch out for the
*rsehole $$$ software with the same name.)
http://sourceforge.net/projects/pdfcreator/ Take a look at the VB
Script options in the C:\Program Files\PDFCreator\Scripts folder.
Figure out which one you need. With a bit of work you can convert the
VBScript code to VBA code.

Tony
 
D

David W. Fenton

Install the open source software PDFCreator. (Watch out for the
*rsehole $$$ software with the same name.)
http://sourceforge.net/projects/pdfcreator/ Take a look at the VB
Script options in the C:\Program Files\PDFCreator\Scripts folder.
Figure out which one you need. With a bit of work you can convert
the VBScript code to VBA code.

Thanks. I'll give it a look when I have the time.
 

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