adamkushner
asked on
Crystal Reports in VB - Error loading report, loads then terminates?
I have a crystal report. The report views fine inside of crystal. When loaded from VB it loads than immediatly terminates. Why would this happen? Following is the code I'm using to call the report.
invoicenumber = Key
SwedishDatabaseLocation = path to database
CR1.ParameterFields(0) = "invoicenumber;" & invoicenumber & ";True;"
CR1.DataFiles(0) = SwedishDatabaseLocation
CR1.ReportFileName = App.Path & "\creport1.rpt"
CR1.PrintReport
Thanks,
Adam
invoicenumber = Key
SwedishDatabaseLocation = path to database
CR1.ParameterFields(0) = "invoicenumber;" & invoicenumber & ";True;"
CR1.DataFiles(0) = SwedishDatabaseLocation
CR1.ReportFileName = App.Path & "\creport1.rpt"
CR1.PrintReport
Thanks,
Adam
ASKER
No, a Crystal Report Control will load the report into a Crystal Default window like a VB Report does.
Crystal will generate errors that are not reported as run time errors and in order to determine the problem place an error trap after the printreport command to determine the cause for this failure:
CR1.PrintReport
If CR1.LastErrorNumber > 0 Then _
MsgBox CR1.LastErrorNumber & " " & CR1.LastErrorString & _
vbCrLf & " This error is occurring during print attempt.", vbOKOnly + vbCritical, "Report Error"
CR1.PrintReport
If CR1.LastErrorNumber > 0 Then _
MsgBox CR1.LastErrorNumber & " " & CR1.LastErrorString & _
vbCrLf & " This error is occurring during print attempt.", vbOKOnly + vbCritical, "Report Error"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
then u must assign the report datasource to the crystal report viewer control on that form CRViewer than
what u r doing now.
CR1.printreport just sent the crystal report to the printer i think. if u want to view your report u need the CRViewer with the crystal report control on it.
i hope you understand me. :)