Link to home
Start Free TrialLog in
Avatar of adamkushner
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
Avatar of spiral
spiral

u will need a form to contain the crystal report let's call it CRViewer

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. :)
Avatar of adamkushner

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"
ASKER CERTIFIED SOLUTION
Avatar of selim007
selim007

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial