Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

5.07 Editing Code

Editing Code


These five buttons assist you with writing formulas. The first button checks the syntax of the formula. If it finds an error in the formula, it prompts you with a message box telling you if there is a syntax error or not. You can check the syntax after you are finished writing the formula or you can do it after each line. Checking the syntax after each line lets you find a problem and correct it before going forward. This is good when you are just learning how to write formulas and you aren’t confident of what you are doing yet. It’s also useful if you are writing a complex formula and you want to double check that you didn’t make a typo.

The next two buttons are the Undo and Redo buttons. You are probably familiar with these from other programs such as Microsoft Word or Excel. The Undo button removes the last change you made. The Redo button puts that change back if you decide that you shouldn’t have clicked the Undo button. It’s like an Undo-The-Undo button. (

The last two buttons help you find information. The magnifying glass browses data of a field. This is the same as the Browse Data button we saw with the report experts. It is only available when a field in the Report Fields window is selected.

The last button is the Find button. As you might expect, it finds the specified text within the formula and highlights it. But that is just one part of its functionality. What is a really nice feature is that it not only searches your formula, but it searches the text within any of the windows. Look at Figure 5-4 to see what the Find dialog box looks like.



Figure 5-4. The Find dialog box gives you advanced search functionality.

Notice in the center of the dialog box that it has radio buttons that specify where to search for the text. It finds text in Fields, Functions, Operators, and Edit Text (the Definition area). If you’ve ever tried to find a function name in the Functions tree, it can be confusing to figure out which node the function is listed under. The Find dialog box finds it for you. And if you only know part of the name, then it does partial text finds as well.

The Find feature also replaces existing text with new text. But this is only enabled for the Edit Text option (you aren’t about to start renaming Crystal functions!) If you want to rename a formula name that is referenced within another formula, remember from before that you don’t have to do this with Crystal Reports. When you rename the formula within the Field Explorer window, Crystal Reports automatically searches throughout the entire report and updates all formula references to use the new name.

Crystal Reports has an auto-complete feature that saves you time typing. When you are typing in a function name you can press CTRL + Spacebar and the rest of the function name will be typed for you. If there is more than one function name that start with the letters you typed in then a drop-down list will appear with all the function names listed in it. This is helpful if you can remember part of a function name but you aren’t sure of what the full name is. Just type in the part you know and press CTRL + Spacebar.

If you are using Crystal Reports XI R2, the auto-complete feature is more advanced. Upon typing the open bracket for a field name, it automatically displays a list of all fields in the data source. You can use the down arrow to find the one you want or continue typing. This also works for formulas, parameters and SQL Expressions.