I am able to open and preview a report via scripting using the SY_ReportEngine. I need to streamline the experience for the end user and just print the report without Previewing it.
I am Trying to use the Printout Method but can't get the syntax correct. I might need to also set the printer options first with the SelectPrinter method but am unsure. Does anyone have some sample code to do this via VBA. I am doing it all External of sage if that matters. I want to click a button in access and run the report.
Here is a snippet of the code Im using.
nReport_Rpt = 0: nReport_Rpt = oSS.nNewObject("SY_ReportEngine") If nReport_Rpt > 0 Then Set oReport_Rpt = oSS.oGetObject("SY_ReportEngine") ' Make sure your report has been converted to the correct level or else the report engine will not open it. If oReport_Rpt.nOpenReport(sReportPath) = 1 Then oReport_Rpt.nSetReportTitle sReportTitle oReport_Rpt.nSetPreviewOptions sReportTitle If oReport_Rpt.nDatabaseLogon() = 1 Then oFormula = "TST-LPS192-95UVCAEFLESH" oLotNumber = "I23-98765" oTotalRequired = "123456" oSelectionFormula = "not ({BM_BillDetail.ComponentItemCode} startswith [" & """SALES-""" & "," & """TECH""" & "," & """Z-""" & "]) and ({BM_BillHeader.BillNo} = " & """" & oFormula & """" & ")" oReport_Rpt.nSetSelectionFormula (oSelectionFormula) oReport_Rpt.nSetFormula "LotNumber", """" & oLotNumber & """" ' Use this to set the value of the formula name specified in the first argument. You must respect the syntax specified in the formula in the report. oReport_Rpt.nSetFormula "TotalRequired", oTotalRequired ' Use this to set the value of the formula name specified in the first argument. You must respect the syntax specified in the formula in the report. oReport_Rpt.nPreview 'oReport_Rpt.nPrintOut "True" 'Not Working. Unsure what to do End if End If End If
Any help on correct systax to output the report direct to printer is appreciated.