Solved

Export individual report to pdf

Posted on 2017-05-15
2
55 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 37

Accepted Solution

by:
PatHartman earned 500 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

Webinar: Security & Encryption in the MySQL world

Join Percona’s Solutions Engineer, Dimitri Vanoverbeke as he presents “Security and Encryption in the MySQL world” on Thursday, July 6, 2017 at 7:00 am PDT / 10:00 am EDT (UTC-7).

Question has a verified solution.

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

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

687 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