Hello everyone,
I am trying to export a multi page report to .pdf files. Each page of the report is a different file, so if there are 50 pages to the report, there should be 50 different .pds files, each with a unique name. I can get it to loop through every page and export a file, with this code, but doesn't create a new name and it just over writes the file 50 times.
But if I try to add the [CustName] field, I get a "Type Mismatch" Error
Below is my complete code. I want the export names to be "PreRegCodes_[CustName]
Thanks for your help
I am trying to export a multi page report to .pdf files. Each page of the report is a different file, so if there are 50 pages to the report, there should be 50 different .pds files, each with a unique name. I can get it to loop through every page and export a file, with this code, but doesn't create a new name and it just over writes the file 50 times.
Code:
outputFileName = CurrentProject.Path & "\PreRegCodes_" & ".pdf"
But if I try to add the [CustName] field, I get a "Type Mismatch" Error
Code:
outputFileName = CurrentProject.Path & "\PreRegCodes_" & [CustName] & ".pdf"
Below is my complete code. I want the export names to be "PreRegCodes_[CustName]
Code:
Public Sub PreRegExport()
Dim MyRs As DAO.Recordset
Dim rpt As Report
Dim outputFileName As String
Set MyRs = CurrentDb.OpenRecordset("qryPreRegBarcode_pdf")
DoCmd.OpenReport "rptFoodshowPreReg", acPreview, , , acHidden
Set rpt = Reports("rptFoodshowPreReg")
With MyRs
.MoveFirst
Do While Not .EOF
rpt.Filter = "[PreRegCode] = " & !PreRegCode
rpt.FilterOn = True
outputFileName = CurrentProject.Path & "\PreRegCodes_" & [CustName] & ".pdf"
DoCmd.OutputTo acOutputReport, "rptFoodshowPreReg", acFormatPDF, outputFileName
.MoveNext
Loop
End With
End Sub
Thanks for your help