Export Reports as Individual PDF (1 Viewer)

aslure

New member
Local time
Today, 07:58
Joined
Jul 2, 2018
Messages
7
So this problem is killing me and I need some VBA help desperately. I am working in a Access 2016 environment and thought this would be easy by now. So I have a report that has all the fields (Including the ID field) from a query and a subreport on the report that connects to one of the fields on the report to pull other information for the report. I also have another page that has the same ID field that continues that report. My pickle here is that how do I export these reports as separate PDFs. Some of these reports are 2 pages. Is there a way I could group them ( I see a group function in the design view) and than export them based on the ID field. I want my output to be "ID".pdf based on the grouped IDs in the report.
 

GinaWhipp

AWF VIP
Local time
Today, 07:58
Joined
Jun 21, 2011
Messages
5,901
Hmm, something like the below (air code)...

Code:
    Dim strSQL As String
    Dim rs As DAO.Recordset
 
        strSQL = "YourQuery"
 
        Set rs = CurrentDb.OpenRecordset(strSQL)
 
        With rs
            .MoveFirst
                Do While Not .EOF
                    DoCmd.OpenReport "rptYourReport", acViewPreview, , "[ID] = " & rs!ID
                    DoCmd.Minimize
                    DoCmd.OutputTo acOutputReport, "rptYourReport", acFormatPDF, "FullPath\" & !ID & ".pdf"
                    DoCmd.Close acReport, "rptYourReport", acSaveNo
 
            .MoveNext
            Loop
        End With
 
        rs.Close
        Set rs = Nothing
 

Users who are viewing this thread

Top Bottom