Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem accessing reports in Crystal Reports 9.0 from VB

Status
Not open for further replies.

tmcgill

Programmer
Aug 11, 2001
4
US
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top