Это может вам помочь
Public Sub OpenReport(ReportPath As String, DataPath As String)
' 1) add a reference to the Crystal Reports 8.5 ActiveX Designer Run Time Library
' 2) place a CrystalActiveXReportViewer control named crView to your form
Dim oCRapp As CRAXDRT.Application
Dim oReport As CRAXDRT.Report
Set oCRapp = New CRAXDRT.Application
Set oReport = oCRapp.OpenReport(ReportPath, crOpenReportByTempCopy)
SetReportDatabase oReport, DataPath
crView.ReportSource = oReport
crView.ViewReport
End Sub
Public Sub SetReportDatabase(CrystalRpt As CRAXDRT.Report, DataPath As String)
Dim oTab As CRAXDRT.DatabaseTable
On Error GoTo errhndl
For Each oTab In CrystalRpt.Database.Tables
' check connection type
If LCase$(oTab.DllName) = "crdb_odbc.dll" Then
With oTab.ConnectionProperties
.DeleteAll
.Add "Connection String", "Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=" & DataPath & ";Uid=Admin;Pwd=MyPassword"
End With
End If
Next oTab
' subreports
Dim rptObj As Object, rptObjs As CRAXDRT.ReportObjects, rptSecs As CRAXDRT.Sections, rptSec As CRAXDRT.Section
Dim subRptObj As CRAXDRT.SubreportObject, oSubTab As CRAXDRT.DatabaseTable
Dim subRpt As CRAXDRT.Report
Set rptSecs = CrystalRpt.Sections
For Each rptSec In rptSecs
Set rptObjs = rptSec.ReportObjects
For Each rptObj In rptObjs
If rptObj.Kind = crSubreportObject Then
Set subRptObj = rptObj
Set subRpt = subRptObj.OpenSubreport
For Each oSubTab In subRpt.Database.Tables
If oSubTab.DllName = "crdb_odbc.dll" Then
With oSubTab.ConnectionProperties
.DeleteAll
.Add "Connection String", "Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=" & DataPath & ";Uid=Admin;Pwd=MyPassword"
End With
End If
Next oSubTab
End If
Next rptObj
Next rptSec
Exit Sub
errhndl:
Err.Raise Err.Number, "SetReportDatabase", Err.Description
End Sub