?
Solved

Export individual report to pdf

Posted on 2017-05-15
2
Medium Priority
?
73 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 38

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Your data is at risk. Probably more today that at any other time in history. There are simply more people with more access to the Web with bad intentions.
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses

764 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