CRD vba code no longer works
I use the crystal report designer i to export a crystal report as a tab separated text from Microsoft Access. The report was originally written in Crystal 8.5 and connected to the Oracle back end database via ODBC.
This code worked:
Public Function ExportCrystalReport(strReportLocation As String, _
strReportFileName As String, _
strExportLocation As String, _
strExportFileName As String, _
Optional intParameterValue As Integer = 0) As Boolean
Dim crxApp As New CRAXDRT.Application
Dim crxReport As CRAXDRT.Report
Dim crxParameter As CRAXDRT.ParameterFieldDefinition
On Error GoTo ErrHandler
Set crxReport = crxApp.OpenReport(strReportLocation & strReportFileName)
crxApp.LogOnServer "pdsora7.dll", "EMS", , "XXXX", "xxxx"
With crxReport
With .ExportOptions
.DiskFileName = strExportLocation & strExportFileName
.DestinationType = crEDTDiskFile
.FormatType = crEFTTabSeparatedText
End With
If intParameterValue = 0 Then
Else
Debug.Print .ParameterFields.Count
Debug.Print .ParameterFields.Item(1).Name
.ParameterFields.Item(1).AddCurrentValue intParameterValue
End If
'Don't prompt for export options
.Export False
End With
Set crxReport = Nothing
crxApp.LogOffServer "pdsora7.dll", "EMS", , "XXXX", "xxx"
Set crxApp = Nothing
ExportCrystalReport = True
CleanUp:
Exit Function
ErrHandler:
ExportCrystalReport = False
MsgBox "Error whilst exporting the report " & strReportFileName, vbCritical
End Function
However, we have since upgraded to crystal 10 standard edition so the ODBC link is no longer available. The report now connects using the Microsoft OLEDB provider for Oracle. I've changed the references in Access so that the "Crystal reports ActiveX Designer Run time Library 10.0" is referenced rather than the 8.5 version. I've also changed the log on server command so that it uses the P2Soledb.dll to connect to the database. This appears to be ok as I can view details about the report (eg crxreport.ReportAuthor) but I now get an error at the ".Export false" line.
Anyone got any ideas? Am I using the correct logonserver line?
|