Crystal Reports 10: The Complete Reference
The Formula Workshop is a dialog box that presents a unified approach to examining, creating, and modifying different types of formulas in your reports . The Formula Workshop not only allows you to display and modify standard report formulas, but also allows creation of report custom functions (covered in Chapter 6) and provides the capability to store custom functions in the central repository (covered in Chapter 7). The Formula Workshop provides access to record and group selection, and custom formatting formulas.
To display the Formula Workshop, either choose Report Formula Workshop from the main pull-down menus , or click the Formula Workshop toolbar button from the Expert Tools toolbar. The Formula Workshop will appear, as shown in Figure 5-1.
The Formula Workshop consists of a folder tree view on the left, two toolbars on the top, and a large area below the toolbars and to the right of the tree view where the Formula Expert or Formula Editor (both discussed later in the chapter) will appear when actually working with a formula.
The tree view contains a list of formula categories available in the Formula Workshop.
-
Report Custom Functions Sharable functions that can be used by any formula in your report (covered in Chapter 6).
-
Repository Custom Functions Sharable functions that have been saved in the repository to be used by every copy of Crystal Reports connected to the repository (the repository is covered in Chapter 7).
-
Formula Fields Formulas that you create for use in just this report (covered in the rest of this chapter).
-
SQL Expression Fields Server-based formulas, using the Structured Query Language (covered in Chapter 16).
-
Selection Formulas Formulas used to control record and group selection. These are the same formulas created using the Select Expert, or the Report Selection Formulas pull-down menu options (covered in Chapter 8).
-
Formatting Formulas Formulas that set appearance of report objects and sections conditionally. These are the same formulas created using the conditional buttons in the Format Editor and Section Expert (covered in Chapters 9 and 10).
If there are available formulas or functions in the desired category, a plus sign will appear next to that category ”just click the plus sign to open up that category and show the available formulas or functions in it. The lack of a plus sign next to a category indicates that no formulas or functions in that category have yet been created.
As Table 5-1 shows, the Formula Workshop toolbar at the top of the dialog box provides quick ways to perform more common Formula Workshop options.
Icon | Description |
---|---|
or ctrl-s | Saves the current formula or function and closes the Formula Workshop. If Crystal Reports detects any errors in the formula or function, you'll be prompted whether or not you wish to save with the error. You may also close the Formula Workshop by clicking the X in the window's upper right-hand corner. |
or alt-s | Saves the current formula or function but leaves the Formula Workshop open. If Crystal Reports detects any errors in the formula or function, you'll be prompted whether or not you wish to save with the error. |
or ctrl-n | Creates a new formula. If you click the button directly, you'll create a new formula or function based on the category selected in the tree view. If you click the small down arrow next to the button, you'll be given a choice of type of formula to create. You may also create a new formula by right-clicking the desired tree view category and choosing New from the pop-up menu. |
| Toggles display of the Formula Workshop tree view on and off. |
| Toggles between viewing the actual code of a selected custom function or the custom function's properties (such as arguments, author, and so forth). See Chapter 6 for more information on this button. |
or alt-x | Toggles between displaying the formula in the Formula Expert (discussed later in the chapter and in Chapter 6) or in the Formula Editor. If you are displaying a formula that consists of something other than use of a single custom function, you'll be warned that clicking this button will erase the current formula. Also, this button won't work while you're creating a custom function. |
or f1 | Displays Formula Workshop, Formula Expert, or Formula Editor online help (depending on which portion of the Formula Workshop is currently displayed when you click the button). |
or f2 | Renames the formula currently selected in the tree view. Clicking this button will place the formula name in the tree view in Edit mode. You may also rename a formula by right-clicking the formula in the tree view and choosing Rename from the pop-up menu, or by just holding you mouse button down for a few seconds after selecting the formula name in the tree. |
or del | Deletes the formula from the Formula Workshop and the report. You may be notified that the formula is being used in the report or that repository function deletions can't be undone and asked to confirm the deletion. You may also delete by right-clicking the formula in the tree view and choosing Delete from the pop-up menu. |
| Expands or contracts the folder you currently have selected in the tree view. For example, if you have the Formula Fields folder selected, clicking this button will open that category and show all the report formulas within the category. Clicking the button again will close the category, showing just the folder with a plus sign next to it. |
| Toggles between showing all Formatting Formula category report objects in the report or only those objects that already contain formatting formulas. For example, if you click this button while viewing the expanded Formatting Formulas category, a limited set of report objects will appear (or none, if there are no existing formatting formulas in the report). This button affects only the Formatting Formulas category in the tree view. |
| Adds the selected report custom function to the repository (see Chapter 7 for more information on adding your own custom functions to the repository). |
| Copies the selected repository custom function to the current report. The custom function will then appear in the Custom Functions portion of the Formula Editor functions tree. See Chapter 7 for more information on adding repository custom functions to your report. |
Not all of the toolbar buttons will be enabled all of the time. Certain buttons and their functions are enabled only when an appropriate formula is selected in the tree view. For example, you can t rename custom functions in the repository or click the Delete button when the record selection formula is highlighted.
Tip | The Formula Workshop toolbar actually consists of several separate toolbars, each of which can be undocked from the top of the Formula Workshop window. Just click on the small gray vertical bar to the left of the different parts of the toolbar and drag to a new location. |
You re not limited to using the Formula Workshop to create, rename, and delete formulas. You can also use the Field Explorer. By choosing the Formula Fields category of the Field Explorer, you can access Field Explorer toolbar buttons, right-click pop-up menus, and keyboard shortcuts as well. Accordingly, there are numerous ways to create a new report formula by using the Field Explorer s Formula Fields category or the Formula Workshop. Once you ve chosen to create a new formula, you ll be asked to supply a formula name. Remember that you re not creating a file on disk when you add a formula, so you don t need to worry about file-naming conventions ”the formula is simply stored inside the .RPT file of your report. Your formula names can contain upper- and lowercase letters , spaces, and anything else that makes them descriptive. Use an easy-to-understand formula name ”not only does it help you to recognize what the formula is when you look at the list of formulas you ve created, but it also is used for the field title when you place a formula in the details section.