Hi. I use the following code in a number of VB apps to execute Crystal Reports. It has worked fine with CR 7.0 and CR 8.0. Now, with upgrade to 9.0, code will not work. Error message is "Unable to load report".
I've played around with some of the references and componenets for 9.0, but haven't had any success. Anyone encountering same problem? Any workaround without incorporating the crystal viewer? Any help would be greatly appreciated.
Thanks. TM.
-------------------------------------------------
Public Sub PrintCrystalReport(CrystalReport As Object, _
Optional ReportName As String, _
Optional criteria As String)
On Error GoTo problems
Dim i As Integer
Dim n As Integer
Dim a As Integer
Dim response As Integer
With CrystalReport
.Connect = "DSN=" & strCurrentServer & ";UID = crystalreports;PWD=crystalreports;DSQ=" & strCurrentDatabase
.ReportFileName = App.Path & "\Reports\" & ReportName
For i = 0 To .GetNSubreports - 1
.SubreportToChange = .GetNthSubreportName(i)
.Connect = "DSN = " & strCurrentServer & ";UID = crystalreports;PWD =crystalreports;DSQ = " & strCurrentDatabase & ""
Next
.SelectionFormula = criteria
.WindowState = crptMaximized
response = MsgBox("Would you like this report sent to the printer?", vbYesNo, "Send Report To Printer"
.PrinterSelect
If response = vbYes Then
.Destination = crptToPrinter 'Print to the Screen
Else
.Destination = crptToWindow 'Print to the window
End If
.Action = 1
End With
Exit Sub
problems:
MsgBox "There was an error trying to print this report.", vbCritical, "CRYSTAL REPORT ERROR"
MsgBox Err.Description
End Sub
I've played around with some of the references and componenets for 9.0, but haven't had any success. Anyone encountering same problem? Any workaround without incorporating the crystal viewer? Any help would be greatly appreciated.
Thanks. TM.
-------------------------------------------------
Public Sub PrintCrystalReport(CrystalReport As Object, _
Optional ReportName As String, _
Optional criteria As String)
On Error GoTo problems
Dim i As Integer
Dim n As Integer
Dim a As Integer
Dim response As Integer
With CrystalReport
.Connect = "DSN=" & strCurrentServer & ";UID = crystalreports;PWD=crystalreports;DSQ=" & strCurrentDatabase
.ReportFileName = App.Path & "\Reports\" & ReportName
For i = 0 To .GetNSubreports - 1
.SubreportToChange = .GetNthSubreportName(i)
.Connect = "DSN = " & strCurrentServer & ";UID = crystalreports;PWD =crystalreports;DSQ = " & strCurrentDatabase & ""
Next
.SelectionFormula = criteria
.WindowState = crptMaximized
response = MsgBox("Would you like this report sent to the printer?", vbYesNo, "Send Report To Printer"
.PrinterSelect
If response = vbYes Then
.Destination = crptToPrinter 'Print to the Screen
Else
.Destination = crptToWindow 'Print to the window
End If
.Action = 1
End With
Exit Sub
problems:
MsgBox "There was an error trying to print this report.", vbCritical, "CRYSTAL REPORT ERROR"
MsgBox Err.Description
End Sub