In the calling sub, printIt(), the line " doReport(me.name, "PDF", "Bay", True)" returns an error, "Expected =".
I have tried renaming both subs, but continue to get the same error.
The sub printIT() will reside in various forms that control reports.
The sub doReports() is in a module and controls the output of the reports, either view or save PDF or print to paper.
nReportNum is a global variable of type integer.
As an aside, if I replace "pathRep" with "TempVars!patha & "reports\"" in docmd.outputTo, the PDF file is viewed, but not saved.
I have tried renaming both subs, but continue to get the same error.
The sub printIT() will reside in various forms that control reports.
The sub doReports() is in a module and controls the output of the reports, either view or save PDF or print to paper.
nReportNum is a global variable of type integer.
As an aside, if I replace "pathRep" with "TempVars!patha & "reports\"" in docmd.outputTo, the PDF file is viewed, but not saved.
Code:
Private Sub printIt()
doReport(me.name, "PDF", "Bay", True)
End Sub
Public Sub doReport(sReport As String, sFormat As String, sTitle As String, bView As Boolean)
Dim pathRep As String
If sFormat = "Print" Then
Dim myNewPrinter As Printer
Set myNewPrinter = Application.Printers(Application.Printer.DeviceName)
DoCmd.OpenReport sReport
Else
pathRep = TempVars!patha & "reports\"
sFormat = "acformat" & sFormat
DoCmd.OutputTo acOutputReport, sReport, sFormat, pathRep & sTitle & nReportNum & ".pdf", bView
End If
End Sub