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

How do I print one report per record in a dataset?

P: 3
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:

Code as Follows (modified to fit in window here)

' Establish all the items I need.
Dim dbs As DAO.Database
Dim qdf As DAO.QueryDef
Dim rst As DAO.Recordset
Dim StartInput As String
Dim EndInput As String
Dim StartDate As Date
Dim EndDate As Date

' Get user inputs for the start and end dates. Then
' convert these inputs from a string to a formatted date.
' These dates are used in the existing query.

StartInput = InputBox("Select the start date in mm/dd/yyyy
format.", "Select a Start Date")
EndInput = InputBox("Select the end date in mm/dd/yyyy
format.", "Select An End Date")
StartDate = Format(StartInput, "Medium Date")
EndDate = Format(EndInput, "Medium Date")

' Create the recordset from the pre-existing parameter
' query. I assume that after this, my dataset has the
' records I want to export to PDF

Set dbs = CurrentDb()
Set qdf = CurrentDb.QueryDefs("Analyst_Feedback")
qdf.Parameters("Start_Date").Value = StartDate
qdf.Parameters("End_Date").Value = EndDate
Set rst = qdf.OpenRecordset


' Execute the Export Single Eval to PDF macro for each
' record. I don't know how to export each record
' individually from the dataset. The report called here
' normally exports from a query that selects the record I'm
' working on in a form.

rst.MoveFirst
Do Until rst.EOF
DoCmd.OutputTo acOutputReport, "Feedback Evaluation
Output - Master", "PDFFormat(*.pdf)", "", True, "", ,
acExportQualityPrint
rst.MoveNext
Loop


End Sub
Dec 6 '13 #1
Share this Question
Share on Google+
1 Reply


P: 3
Sorry for wrong forum. Reposted to Access. How can I delete this from this forum?
Dec 6 '13 #2

Post your reply

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