Good afternoon,
I tried combining two print events I had in two separate databases. The first one just gives a print preview of the current record. The second one prints the report to a pdf and saves it in the specified folder.
However, when I try combining the two events, the pdf is not creating. I would greatly appreciate if someone could review and advise where I'm going wrong.
I tried combining two print events I had in two separate databases. The first one just gives a print preview of the current record. The second one prints the report to a pdf and saves it in the specified folder.
However, when I try combining the two events, the pdf is not creating. I would greatly appreciate if someone could review and advise where I'm going wrong.
Code:
Private Sub CmdPrintTender_Click()
Dim strWhere As String
If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If
If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[TenderNo] = """ & Me.[TenderNo] & """"
DoCmd.OpenReport "RPTProspectiveWorks", acViewPreview, , strWhere
End If
Dim FileName As String
Dim FilePath As String
FileName = Me.TenderNo & " - " & Me.ProjectName
FilePath = "J:\Tender Detail Forms" & FileName & ".pdf"
DoCmd.OutputTo acOutputReport, "RPTProspectiveWorks", acFormatPDF, FilePath
MsgBox "Tender Detail Form has been successfully created and saved to J:\Tender Detail Forms", vbInformation, "Enter Tender Details"
End Sub