Error Handling


You need to set up error-handling code for all aspects of RDC programming. As you manipulate the Report object itself (setting properties and executing methods ), you need to plan for the possibility that errors may occur. And if you use the Report Viewer in your application, it can also throw errors for any number of reasons. Add error-handling logic accordingly .

All Report object and Report Viewer errors will appear as regular Visual Basic run-time errors. These need to be trapped with an On Error Goto routine. The hard part is trying to figure out what error codes to trap. Unfortunately, Business Objects has yet to provide comprehensive documentation for the errors that either the Report or Report Viewer objects might throw. In many situations, you ll see typical VB-type error codes for report- related errors. For example, supplying a string index argument to a Report object collection that accepts only integer arguments won t generate an RDC-specific error; instead, Type Mismatch will be returned. However, certain error messages that are Report- or Report Viewer “specific generally throw errors that start with “2147 and are followed by six other numbers .

You ll simply have to test your application thoroughly and create error-handling code appropriately. Try intentionally creating any Report- or Report Viewer “related errors that have even a remote chance of occurring. You can then determine what corresponding error codes the Report or Report Viewer objects throw, and add code to trap those specific errors. Here s sample code from the Xtreme Orders application that traps potential errors when setting Report properties at run time:

 cmdOK_Click_Error: 
Screen.MousePointer = vbDefault
Select Case Err.Number
Case -2147190889
MsgBox "Report Cancelled", vbInformation, "Xtreme Order Report"
Case -2147190908
MsgBox "Invalid E-Mail address or other e-mail problem", _
vbCritical, "Xtreme Order Report"
txtAddress.SetFocus
Case Else
MsgBox "Error " & Err.Number & " - " & Err.Description, _
vbCritical, "Xtreme Order Report"
End Select 'Case Err.Number



Crystal Reports 10
Crystal Reports 10: The Complete Reference
ISBN: B005DI80VA
EAN: N/A
Year: 2004
Pages: 223
Authors: George Peck

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net