Hi Scott
Thanks for the code snippet. I am still having trouble with exporting the report to a PDF file.
Please see the code snippet below:
- Code: Select all
With JiwaPrintReportObject
If Not .LoadReport(QuoteReportPath) Then
MsgBox "Error loading quote report " & QuoteReportPath & ":" & .ErrorString, vbCritical + vbInformation, "Jiwa"
.CleanUp
Set JiwaPrintReportObject = Nothing
rtnCancel = True
Exit Sub
End If
End With
With SalesQuoteObject.Database
SQL = "select a.invoiceno, a.currenthistoryno, b.invoicehistoryid from qo_main a inner join qo_history b on a.invoiceid=b.invoiceid and a.currenthistoryno=b.historyno where a.invoiceno between " & .FormatChar(StartingQuoteNo) & " and " & .FormatChar(EndingQuoteNo) & " order by invoiceno"
ReadHandle = .StatementOpen(.ConnectionRead1)
If .ExecuteSelect(CInt(ReadHandle), SQL, True) Then
While .FetchRow(CInt(ReadHandle))
CurrentQuoteNo = .GetData(CInt(ReadHandle), 1)
CurrentHistoryNo = .GetData(CInt(ReadHandle), 2)
CurrentInvoiceHistoryID = .GetData(CInt(ReadHandle), 3)
With JiwaPrintReportObject
.ResetReportSelectionFormulaTokens
.AddReportSelectionFormulaToken "{@Pass_CurrentHistNo}", Right("00" & CurrentHistoryNo, 2)
.AddReportSelectionFormulaToken "{@Pass_QuoteNo}", CurrentQuoteNo
.AddReportSelectionFormulaToken "{@Pass_SP_QuoteHistoryID}", CurrentInvoiceHistoryID
If .UpdateReport = e_PrintReportReturnCodeSuccess Then
With .CrystalReportObject.ExportOptions
.DestinationType = crEDTDiskFile
If FileType = "XLS" Then
.FormatType = crEFTExcel97
Else
.FormatType = crEFTPortableDocFormat
.PDFExportAllPages = True
End If
.DiskFileName = QuoteFolder & CurrentQuoteNo & "." & FileType
End With
.CrystalReportObject.Export False
Else
MsgBox "Unable to export quote report for " & CurrentQuoteNo & ":" & .ErrorString, vbCritical + vbInformation, "Jiwa"
End If
End With
Wend
Else
MsgBox "Error retrieving quotes to print : " & .ErrorMessage, vbCritical + vbInformation, "Jiwa"
JiwaPrintReportObject.CleanUp
Set JiwaPrintReportObject = Nothing
Set FSO = Nothing
rtnCancel = True
Exit Sub
End If
.StatementClose CInt(ReadHandle)
End With
I am getting an error at UpdateReport method. The actual error message is "The string is non-numeric". As I am testing with a standard Jiwa report, I can't see what could be triggering this error. I am not sure if you have come across similar issue before or not that could explain this behaviour.
In addition, as you can see from my code, I am exporting out a set of quote reports to disk. Do I know need to call cleanup and setup on JiwaPrintReport object each time before I export, or the current way I am doing it is fine?
Thanks
Changsen