473,320 Members | 1,976 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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

Access 2010 on Windows 7 OS (However, eventually moving to secured system running Access 2007. This system won't allow any add-ons...so 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)
  4.  
  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")
  11.  
  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
  19.  
  20.  
  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
  30.  
  31.  
  32. End Sub 
Dec 6 '13 #1
1 2993
zmbd
5,501 Expert Mod 4TB
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

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

Similar topics

0
by: Thomas 'Skip' Hollowell | last post by:
My Struts application is attempting to export the contents of a table to a CSV text file. I have gotten this to work in the past but am now having trouble after the export in getting the...
10
by: Neil | last post by:
Hi guyz, just trying out this google feature so if i post if in the wrong area i appologize. now to my question. BTW i'm new to access programming, i've done a little vb6.0 and vb.net but access...
2
by: pnp | last post by:
Could I export a .NET executable file to an executable that doesn't need the ..NET framework to function? Thanks Peter
13
by: Hemant Sipahimalani | last post by:
The following piece of code is being used to export HTML to excel. HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"...
4
by: mina | last post by:
One of my client want to export data into excel file but he can not installed office just installed excel and want to export file into ..xls format at that time he got error .... Retrieving the...
19
by: jason2412 | last post by:
Hi, Not sure if this is the right place to post this query so apologies in advance. I have two columns in an access table. Example for 2 records: Field 1 - Retail Field 2 - Sat
1
by: Abhishek Bhatt | last post by:
Need to export table into csv file. Tried following: DoCmd.TransferText acExportDelim, "", TABLENAME, "C:\abc.csv", False, "" But the exported file contains data enclosed in double quotes i.e....
3
by: Wayne | last post by:
I'm trying to automate the export of a query to a text file using code. If I export the query manually I get the exact result that I want i.e. If I select the query then choose File/Export from...
5
by: sumanta123 | last post by:
Dear Sir, How to export/import the excel file in oracle database using sql promt. Please guide me the command(export/import) for the neddful. Thanks in Adavance. Regards Sumanta Panda
17
by: timleonard | last post by:
I seem to be over my head and can use some help... I have pieced together some code from several internet searched that is supposed to export a query from access to an existing excel file. I also...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.