Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

5.14 Error Checking Reports

Error Checking Reports

This chapter gave you an introduction to using the Formula Workshop and the next chapter dives deeper into writing programming code. But before you jump in the water head first, you need to be aware of the debugging tools available to you. No matter how good your intentions are of writing the best formulas, things will occasionally go wrong. This section addresses understanding error messages, validating a report for errors, and fixing errors found while a report is running.

Understanding Error Messages

If you have any experience with writing programs or macros, then you know that computers have a strict set of rules that must be followed when you are telling them what to do. If you make a mistake, even something that seems as insignificant as a missing comma, the computer can’t run the program. This is called a syntax error. When a syntax error is found in Crystal Reports, a message box appears informing you of the problem. This message can be as useful as “A string is required here” and you know that you need to replace the number or date value with a String value. Sometimes the error messages are very generic and don’t really give you any idea of what the problem really is. In these cases you have to get creative and try to figure out what is wrong.

Finding an error in your program is never any fun. Sometimes they are easy to fix and other times it can be quite frustrating. The Crystal Reports help file has two good sections for helping you resolve error messages. Go to the help file and click on the Search tab. Type in the following phrase, “Error Messages and Formula Compiler Warnings” and click the List Topics button. The first title found is the one you want to read. It lists all the error messages and tells you what causes them. It also gives you hints on how to fix them. The second help section is found by clicking on the Index tab and typing in “Error Messages, Described”. It lists each error message on its own page and you click through each page to find the error message you want to read. This is harder to use when you want to find a specific error because you don’t know which page it is on. But when you do find it, it is more helpful because there is a lot more detailed information to read.

If you find a syntax error in your formula, you are not required to correct it right away. You can save it as is, and come back later to fix it. This is helpful when you are too busy to figure out what went wrong or you need to find someone to ask for help. Just don’t forget to come back and fix it or else your report won’t run properly.

Validating Reports with the Dependency Checker

Not only can you have syntax error in formulas, but there are many types of problems that can occur in a report. Function names can be typed wrong, links can be broken, and database fields can change. In a complex report it can be very difficult to verify the correctness of everything that might be wrong. Luckily, Crystal Reports makes this easy for you.

Crystal Reports has a new feature called the Dependency Checker which searches through a report and finds everything wrong. It looks at many different aspects of a report and creates a list of everything it finds that needs fixing. Table 5-2 lists the different parts of a report that get evaluated.

Table 5-2. The Dependency Checker features.

Part Checked Description
Formulas, Functions and SQL Expressions Compiles the formulas and functions in a report and checks for errors. Looks for syntax errors as well as missing functions.
Hyperlinks Verifies that the hyperlinks are valid.
Database Verifies that the database connection exists and that the fields the report references are in the tables.
Subreports Checks that any external subreports are located in the proper location. If the subreport has been moved, an error is reported.

The Dependency Checker is run by selecting the menu options Report > Check Dependencies. This opens the Dependency Checker window which lists the errors found and their location.



Figure 5-12. The Dependency Checker window

Each error in the Dependency Checker is listed along the left and its location is listed to the right. You can go directly to the object causing the error by double-clicking on the error message or selecting it and pressing the Enter key. Not all errors need to be fixed. Icons that are a yellow caution sign should be looked at but will not prevent the report from running. For example, a link may be broken on your computer because your network link is disconnected, but it will work fine when the report is run in a production environment. Icons with a red stop sign and an X in the middle are critical errors. You should fix them prior to finalizing the report.

If no errors are found in the report, a green checkmark is displayed.

Setting Which Options to Check

The Dependency Checker doesn’t have to run every type of test on a report. You can disable certain tests from being called by the Dependency Checker. This is done with the Option dialog box on the Dependency Checker tab. Select the menu options File > Options.



Figure 5-13. The Dependency Checker options.

The options tab is broken into two groups. The first group lists the categories of error checking that are done within the current report. For example, if you know that your computer doesn’t have an active link to the current database, then you can turn off the Verify Database option. The changes you make here are saved with the current report and don’t effect other reports.

The second group lists categories related to validating across multiple reports. This applies to users who have the Crystal Reports Server or Business Objects Enterprise.