I have a database that has one table with almost all of my data (it's imported from SharePoint). I am trying to export each record as a single PDF but am having some issues. I found the below code on this site but can't seem to get it to work. Every time I run it, it gives me a PDF names with the ID that includes all of the records. It will then increment the ID and give me a new PDF with all of the records. The ID i'm using is the autonumber ID for the Local_COVID_Tracker table and the table is a local copy of the linked SharePoint table (or list as they call it). I've tried everything I know and can't figure it out. And I apologize, it has been about 20 years since I have had to do anything like this...my day to day job is in law enforcement, not databases or programming. Haha.
Also at some point I would like to make the file names the names of the patients and not the ID. That might be a whole other post since the names in Local_COVID_Tracker are numbers linked to another table with user info.
Thanks in advance - Mike
Also at some point I would like to make the file names the names of the patients and not the ID. That might be a whole other post since the names in Local_COVID_Tracker are numbers linked to another table with user info.
Thanks in advance - Mike
Code:
Public Sub ExportToPDF()
Dim ReportName As String
Dim OutputFolder As String
Dim rs As DAO.Recordset
ReportName = "PrintOutReport"
OutputFolder = "C:\Users\mrnevitt\test"
Set rs = CurrentDb.OpenRecordset("SELECT ID FROM Local_COVID_Tracker")
Do While Not rs.EOF
DoCmd.OpenReport ReportName, acViewReport, "ID = '" & rs!ID & "'", , acHidden
DoCmd.OutputTo acOutputReport, ReportName, acFormatPDF, OutputFolder & "\" & rs!ID & ".PDF"
DoCmd.Close acReport, ReportName
rs.MoveNext
Loop
rs.Close
End Sub
Last edited by a moderator: