Hello,
I have a question how to save multiple reports to PDF. How do I save them into individual page by order# instead save them all into one page by individual order#? I have a form that users enter Order date and Location. When I click Save Reports, if I have four order#, it save four reports but each report combined all four reports together. Is any way I can save as individual Report? Any help would be grate appreciate!
Here are my code:
Thank you for your time!
I have a question how to save multiple reports to PDF. How do I save them into individual page by order# instead save them all into one page by individual order#? I have a form that users enter Order date and Location. When I click Save Reports, if I have four order#, it save four reports but each report combined all four reports together. Is any way I can save as individual Report? Any help would be grate appreciate!
Here are my code:
Code:
Option Compare Database
Option Explicit
Dim RecordOne as Boolean
Dim stDocName as string
Dim NumberofRecords as Integer
Dim FilePath as String
Private Sub MoveToNextRecord()
DoCmd.GoToRecord, , acNext
Private Sub SavetheRecord()
FilePath = Environ("UserProfile") & "\OneDrive\Order\"
If Me.Location = "PA"
stDocName = "rptOrderA
DoCmd.OutPutTo acOutputReport, "rptOrderA", acFormatPDF, FilePath & Me.Docket & "-rptOrderA.pdf"
stDocName = "rptOrderB
DoCmd.OutPutTo acOutputReport, "rptOrderB", acFormatPDF, FilePath & Me.Docket & "-rptOrderA.pdf"
Else
stDocName = "rptOrderA
DoCmd.OutPutTo acOutputReport, "rptOrderA", acFormatPDF, FilePath & Me.Docket & "-rptOrderA.pdf"
End if
Private Sub SaveReports_Click()
On Error GoTo Err_SaveReports_Click
FilePath = Environ("UserProfile") & "\OneDrive\Order\"
For x= 1 To NumberofRecords
SavetheRecord
If x < NumberofRecords then
MoveToNextRecord
End if
Next x
stDocName = "rptConfirmLetter"
DoCmd.OutPutTo acOutputReport, "rptConfirmLetter", acFormatPDF, FilePath & Me.Docket & "-rptOrderA.pdf"
DoCmd.Close acForm, "frmOrderBatch"
Exit_SaveReports_Click:
Exit Sub
Err_SaveReports_Click:
Msgbox Err.Description
Resume Exit_SaveReports_Click
End Sub
Thank you for your time!