catherinebush
New member
- Local time
- Today, 06:42
- Joined
- Nov 2, 2012
- Messages
- 5
I am new to this group and to this forum. I am trying to loop through a query, then save each record in the query to a pdf.
Query - ReceivedExportQuery
Report - EligibleEmployees
I want to save each record as the employee name.
I have read through most of the threads and have written the following code. It does save the report for each individual; however, it saves the report with all records. What changes to I have to do to make it save each record individually in a report?
Thanks for your help.
Dim rs As DAO.Recordset
Dim db As DAO.Database
Dim mypath As String
mypath = "C:\Users\Desktop\"
Set db = CurrentDb
Set rs = db.OpenRecordset("ReceivedExportQuery")
rs.MoveFirst
Do Until rs.EOF
DoCmd.OpenReport "EligibleEmployees", acViewReport, "Name"
DoCmd.OutputTo acOutputReport, "", acFormatPDF, mypath & rs!Name & ".pdf"
DoCmd.Close acReport, "Test"
rs.MoveNext
Loop
Set rs = Nothing
Set db = Nothing
End Sub
Query - ReceivedExportQuery
Report - EligibleEmployees
I want to save each record as the employee name.
I have read through most of the threads and have written the following code. It does save the report for each individual; however, it saves the report with all records. What changes to I have to do to make it save each record individually in a report?
Thanks for your help.
Dim rs As DAO.Recordset
Dim db As DAO.Database
Dim mypath As String
mypath = "C:\Users\Desktop\"
Set db = CurrentDb
Set rs = db.OpenRecordset("ReceivedExportQuery")
rs.MoveFirst
Do Until rs.EOF
DoCmd.OpenReport "EligibleEmployees", acViewReport, "Name"
DoCmd.OutputTo acOutputReport, "", acFormatPDF, mypath & rs!Name & ".pdf"
DoCmd.Close acReport, "Test"
rs.MoveNext
Loop
Set rs = Nothing
Set db = Nothing
End Sub