question

TrevDM-1820 avatar image
0 Votes"
TrevDM-1820 asked

Print each page of a report to separate pdf file by field criteria

Hey Everyone, I’m trying to export a 7 page document (7 suppliers , 1 supplier to a page) to 7 individual PDF not 1 PDF with 7 pages, I've tried to research and recreate but it’s not working so thought I 'd ask the question, below is my VBA code.

Currently my query to collect the data pulls 48 lines, when running the below, it prints 48 PDFS each pdf holding 7 pages

This action occurs on a button.on_click function in VBA


 Dim strR As String
 Dim strWhere As String
    
 strR = "3_Rpt_hardware_new_request"
 Set rs = CurrentDb.OpenRecordset("3_Qry_hardware_new_request")
    
 With rs
 .MoveFirst
 Do While rs.EOF = False
    
 strWhere = "SupplierID = " & rs!SupplierID
 MsgBox strWhere
    
 DoCmd.OpenReport strR, acViewPreview, strWhere, , acHidden
 InvoiceNumber = "DPO" & Format(SupplierID, "00") & Format(Date, "mmdd")
    
 Number = CStr(InvoiceNumber)
    
 DoCmd.OutputTo acOutputReport, strR, acFormatPDF, Environ("UserProfile") & "\Desktop\" & Number & ".pdf", False
 DoCmd.Close acReport, strR
 .MoveNext
 Loop

 End With






office-vba-dev
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

0 Answers