Parameter fields can be used to customize other parts of the report, not just record selection. If a viewer wishes to highlight orders over a certain amount, they can specify the amount in a parameter field and use the parameter field to set conditional formatting. If they wish to see summary data instead of detail data, they can respond to a Boolean parameter field that is used to suppress the details section. Basically, any place you can specify formatting conditionally, you can base formatting on parameter fields just as easily as you can on database or formula fields.
Once a parameter field has been created, it can be used for conditional formatting just as easily as any database or formula field. As with any parameter field, you need to consider the value type used to create the parameter field. For example, you might wish to prompt the viewer for an order amount threshold to highlight orders over that amount in red. If the Order Amount field in the database is contained in a currency data type, you ll need to either create the parameter field with the currency data type or do some data-type conversion in the conditional formula.
For example, you may wish to change various formatting properties of both report objects and sections based on a parameter. A currency parameter field will prompt the viewer to enter an order amount threshold. Then, two conditional formulas can be created: one to set the background color of the details section and one to set the font color of the order amount and customer name fields. The details section background color can be formatted to display in silver if the order exceeds the parameter value, as follows :
If {Orders.Order Amount} > {?Order Level} Then Silver Else NoColor
Then, another conditional formula, when applied to the font color of both the order amount and customer name, will display the fields in red if the order amount exceeds the threshold:
If {Orders.Order Amount} > {?Order Level} Then Red Else Black
Figure 14-4 shows the result when a threshold of $1,000 is supplied to the parameter field prompt.
Caution | Since the Highlighting Expert allows you only to compare to actual database values to set formatting conditionally, the Highlighting Expert will not work with parameter fields. You must use the Conditional Formula buttons that appear in the Format Editor if you wish to conditionally format with parameter fields. |
Use a parameter field just like a database or formula field to conditionally suppress individual objects or sections. Since the Suppress property requires a Boolean formula when being set conditionally, you can create a Boolean parameter field and supply it as the sole part of the Boolean formula, or you can create a Boolean formula by using a comparison operator with another type of parameter field.
You could, for example, create a Boolean parameter field called Summary Only that returns a true or false value based on the viewer s choice. By simply supplying the Boolean parameter field as the only item in a section or object s Suppress conditional formula, you could control whether the details section or a page header section containing column headings for the details section appears or doesn t appear.
When prompted for this parameter field, the viewer could select a True or False option for the Summary Only parameter field. You could then place this parameter field directly in the Suppress conditional formula for the details section. If the Summary Only parameter were true (indicating that the viewer wants a summary-only report), the details section would be suppressed. You could also suppress the page header section that contains column headings for the details fields.
A Password parameter can be used to conditionally format a sensitive data field, such as Salary, to suppress if {?Password} does not equal a certain value. Since the password is masked by asterisks when the viewer enters it, it s protected from inadvertent over-the- shoulder viewing, and only people who enter it correctly will see the sensitive data. Note, however, that anyone with access to the report and to the Crystal Reports Designer can simply view the conditional formatting formula to determine the password value required, so the password edit mask is not, in itself, a security measure for sensitive data.