Solved

Export individual report to pdf

Posted on 2017-05-15
2
37 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
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.

Join & Write a Comment

When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
Use Windows Task Scheduler to print a Word document weekly so your printer ink won't dry out.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

737 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