Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Export individual report to pdf

Posted on 2017-05-15
2
Medium Priority
?
96 Views
Last Modified: 2017-05-18
Dear Experts.

I have an Access 2007 database with 300 results from a survey, each of the 300 people surveyed answered a dozen questions which are being analysed.  

What I also need to do is produce a separate pdf report for each person surveyed (each person's results are between 1 to 2 pages in length) ie 300 different pdfs.

The results are all housed in a table called "FinalResults" and are fed through to the report from a query called "IndividualReportQuery".  The report itself is called "Individual Report" and there is a unique ID for each record called "ID" which is what I would like to use as the name for each pdf.

I have thought of exporting the whole report as a pdf & then use a pdf splitter, but each record can be 1 or 2 pages in length.

The only other way I was thinking was to somehow use a recordset clone ... basically create a query for the 1st record in the report (ie select all from XXX where ID = "123456") & use this as the dataset for the report.  Then export the report, once done then the last bit of vba would be to delete the newly created query and repeat this process 300 times.


Can anybody help or have other ideas of how to tackle this?

Many thanks
0
Comment
Question by:correlate
2 Comments
 
LVL 40

Accepted Solution

by:
PatHartman earned 2000 total points
ID: 42135743
I'm a little pressed for time, so I'll give you pseudo code.

Change the report to reference a field on a form for criteria.  If you ever want to print all records, make the criteria optional

Where (someID = Forms!myform!myhiddensomeID  OR  Forms!myform!myhiddensomeID Is Null)

Open a query that selects the 300 people whose surveys you want to print
For each person in the query
    Me.myhiddensomeID = rs!someID
    sOutFileName = sOutFolderName & "somefixedportion" & Format(Date(), "yyyymmdd") & "_" & Me.someID & ".pdf"
    DoCmd.OutputTo acOutputReport, "reportname", acFormatPDF, "filename"
Next

The problem is caused because the OutputTo does not take a runtime Where argument similar to OpenReport and OpenForm so you have to work around the issue.  Another method is to open the report using the where argument and then print the report to the pdf but I find this method awkward and slower for large numbers of reports.
0
 

Author Closing Comment

by:correlate
ID: 42140640
Perfect, works a treat, thank you very much
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Among the most obnoxious of Exchange errors is error 1216 – Attached Database Mismatch error of the Jet Database Engine. When faced with this error, users may have to suffer from mailbox inaccessibility and in worst situations, permanent data loss.
A Case Study of using the Windows API to provide RS232 communications capability in Access without the use of Active-X controls.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question