PDA

View Full Version : Export Crystal Report from Access 2010 64bit



halalseri
12-07-2016, 07:08 PM
Dear All,
I use the following code to export the report to PDF and it is working in MS access 32bit but when I tried to run it in the 64bit I get error #420 "ActiveX component can't create object". I registered the lib "CRAXDRT.dll" and still have the same error. Please hepl me.

Public Const REPORT_LOC As String = "D:\Report.rpt"
Public Sub GenerateLocalRepReport2()
Dim crystalApp As New CRAXDRT.Application
Dim crxTable As CRAXDRT.DatabaseTable
Dim crystalReport As New CRAXDRT.Report
Dim exportOpts As ExportOptions

Set crystalReport = crystalApp.OpenReport(REPORT_LOC)
crystalReport.DiscardSavedData

On Error GoTo BadCrystalConnection
For Each crxTable In crystalReport.Database.Tables
crxTable.ConnectionProperties.DeleteAll
crxTable.ConnectionProperties.Add "DSN", "XYZ"
crxTable.ConnectionProperties.Add "Database", "XYZ"
crxTable.ConnectionProperties.Add "User ID", "sa"
crxTable.ConnectionProperties.Add "Password", "sa"
crxTable.Location = crxTable.Location

Next crxTable
On Error GoTo 0

crystalReport.ParameterFields(1).AddCurrentValue "A2002"
exportOpts = New Report.ExportOptions
crystalReport.ExportOptions.FormatType = crEFTPortableDocFormat
crystalReport.ExportOptions.DiskFileName = "D:\Report_1.pdf"
crystalReport.ExportOptions.DestinationType = crEDTDiskFile
crystalReport.Export False

Exit Sub

BadCrystalConnection:
MsgBox "The DSN connection string for Crystal Reports is invalid"
End Sub