This is really a good solution.
However when I export the report with parameters, I got run-time-error 20540 "missing or out-of-date export DLL". The error is on this statement- Call PcrpReport.Export(False)
But it ran smoothly to export other reports with no parameter by using this statement.
So, does anyone know which DLL I need to solve this problem?
Thanks!!
Below is my code:
=====================
Public POrID As String
Public POrcInst As String
Public POrcName As String
Public POrID2 As String
Public PConn As New ADODB.Connection
Public PcrpApplication As New CRPEAuto.Application
Public PcrpReport As CRPEAuto.Report
Public PcrpPageOptions As CRPEAuto.PageSetup
Public PcrpExportOptions As CRPEAuto.ExportOptions
Public Sub ExportReport()
Dim vRptName, PExpRptName As String
Dim VendorSQL As String
Dim VendorRS As New ADODB.Recordset
Dim x As Long
vRptName = "C:\CrystalTest\VendorReport.rpt"
Set PcrpReport = PcrpApplication.OpenReport (vRptName)
PcrpReport.Database.Tables(1).SetLogOnInfo POrcName, POrcInst,
POrID, POrID2
Set PcrpExportOptions = PcrpReport.ExportOptions
PcrpExportOptions.DestinationType = crEDTDiskFile
VendorSQL = "SELECT DISTINCT VendorCode, VendorName from Vendor "
VendorRS.Open VendorSQL, PConn, adOpenDynamic
Do While Not VendorRS.EOF
x = 1
For x = 1 To PcrpReport.ParameterFields.Count
Select Case PcrpReport.ParameterFields.Item(x).Name
Case "{?parAgentName}"
PcrpReport.ParameterFields.Item(x).SetCurrentValue
Trim(VendorRS!VendorName)
Case "{?Parameter2}"
crxrpt.ParameterFields.Item(x).SetCurrentValue
"Parmater 2 Value"
Case "{?Parameter3}"
crxrpt.ParameterFields.Item(x).SetCurrentValue
"Parmater 3 Value"
End Select
Next x
PExpRptName = "C:\CrystalTest\VendorReport" &
Trim(VendorRS!VendorCode) & ".rtf"
PcrpExportOptions.DiskFileName = PExpRptName
Call PcrpReport.Export(False)
VendorRS.MoveNext
Loop
Set PcrpReport = Nothing
Set PcrpExportOptions = Nothing
End Sub