Hi,
I have this section of code handling the export of a single report into a pdf file into a specific pre-determined location. I would like to make it so that the export combines 2 reports as it is exporting into the pdf. I dont know where to begin. also I apologize for the code in advance I made this several years ago and its been in my archive folder since and I recently pulled it out and am starting to work on this again.
I have this section of code handling the export of a single report into a pdf file into a specific pre-determined location. I would like to make it so that the export combines 2 reports as it is exporting into the pdf. I dont know where to begin. also I apologize for the code in advance I made this several years ago and its been in my archive folder since and I recently pulled it out and am starting to work on this again.
Code:
Private Sub Command21_Click()
Dim fileName As String, fldrPath As String, filePath As String
Dim answer As Integer
Dim fileName2 As String
DoCmd.OpenForm "Specific_Information_frm"
'filename for PDF file*
fileName = "C-Scan Report"
fileName2 = Forms![Specific_Information_frm]![WBS Number]
'folder path where pdf file will be saved *
fldrPath = "C:\Users\#######\OneDrive - #####\Desktop"
filePath = fldrPath & "\" & fileName2 & " " & fileName & ".pdf"
'check if file already exists
If FileExist(filePath) Then
answer = MsgBox(prompt:="PDF file already exists: " & vbNewLine & filePath & vbNewLine & vbNewLine & _
"Would you like to replace existing file?", buttons:=vbYesNo, Title:="Existing PDF File")
If answer = vbNo Then Exit Sub
End If
On Error GoTo invalidFolderPath
DoCmd.OutputTo objecttype:=acOutputReport, objectName:=Me.Name, outputformat:=acFormatPDF, outputFile:=filePath
DoCmd.Close acForm, "Specific_Information_frm"
DoCmd.Close acReport, "C-Scan_rpt"
MsgBox prompt:="PDF File exported to: " & vbNewLine & filePath, buttons:=vbInformation, Title:="Report Exported as PDF"
Exit Sub
invalidFolderPath:
MsgBox prompt:="Error: Invalid folder path. Please update code.", buttons:=vbCritical
End Sub