By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,255 Members | 2,575 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,255 IT Pros & Developers. It's quick & easy.

How do I export each individal recordset records to a .pdf file?

P: 3
Access 2010 on Windows 7 OS (However, eventually moving to secured system running Access 2007. This system won't allow any I need to do this in Access with nothing added on.)

I'm very new to VBA and need help with a code. To summarize, I'm trying to use an existing parameter query to create a dataset. Then, I need to go through that dataset record by record, and export each record to an individual .pdf file. There will only be 10-20 records each month to do. I'm wondering if just running the query and doing each record manually is better:

Expand|Select|Wrap|Line Numbers
  1.  ' Establish all the items I need.
  2. Dim dbs As DAO.Database
  3. 'After this I enter all elements below (omitted for space)
  5. ' Get user inputs for the start and end dates.  Then convert these inputs from
  6. ' a string to a formatted date.  These dates are used in the existing query.
  7. StartInput = InputBox("Select the start date in mm/dd/yyyy format.", "Select a Start Date")
  8. EndInput = InputBox("Select the end date in mm/dd/yyyy format.", "Select An End Date")
  9. StartDate = Format(StartInput, "Medium Date")
  10. EndDate = Format(EndInput, "Medium Date")
  12. ' Create the recordset from the pre-existing parameter query.  I assume that
  13. ' after this, my dataset has the records I want to export to PDF
  14. Set dbs = CurrentDb()
  15. Set qdf = CurrentDb.QueryDefs("Analyst_Feedback")
  16. qdf.Parameters("Start_Date").Value = StartDate
  17. qdf.Parameters("End_Date").Value = EndDate
  18. Set rst = qdf.OpenRecordset
  21. ' Execute the Export Single Eval to PDF macro for each record.  I don't know
  22. ' how to export each record individually from the dataset.  The report called
  23. ' here normally exports from a query that selects the record I'm working on
  24. ' in a form.
  25. rst.MoveFirst
  26. Do Until rst.EOF
  27.   DoCmd.OutputTo acOutputReport, "Feedback Evaluation Output - Master", "PDFFormat(*.pdf)", "", True, "", , acExportQualityPrint
  28.   rst.MoveNext
  29. Loop
  32. End Sub 
Dec 6 '13 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 5K+
P: 5,397
With ACC2007 you may have an issue, from, my understanding, the native install did not directly support PDF export. There is an update that must be applied.

As for your code, before we spend alot of time looking thru it, does it currently do what you need?
I noticed that there were a few errors in it - corrected should be:
DoCmd.OutputTo acOutputReport, "Feedback Evaluation Output - Master", acFormatPDF, , True, , , acExportQualityPrint
This way it will export to the correct format and prompt you for the file location for save.
If you want to automate this, then we can insert a variable with the full path - define it the path for each record within your loop and then call the command:
DoCmd.OutputTo acOutputReport, "rpt_qry_peoplr", acFormatPDF, strPathAndFileName, True, , , acExportQualityPrint

Try the fix to the code and see what you get, let us know.
Dec 6 '13 #2

Post your reply

Sign in to post your reply or Sign up for a free account.