Conditional FormattingUsing Data to Drive the Look of a Report

Conditional Formatting Using Data to Drive the Look of a Report

Up to now, the focus has been on static, non-changing formatting. The next step in making reports as presentable as possible is to apply formatting based on the data that is being returned from a field or even applying formatting on one field based on the value of another.

Conditional formatting relies on the formula language to be used. This is advantageous because the formula language is very extensive. Very complex statements can be made within the formula language to make very complex formatting formulas for use in reports. For this hour, the tutorials will stick with relatively simple examples. For more tips and tricks on using the formula language, see Hour 17, "Using Formulas and Custom Functions to Implement Complex Business Logic."

The simplest way to do this is to use the Highlighting Expert. This feature allows you to quickly and easily apply font face and font color changes to database fields based on their values. For more information on this feature, see Hour 5.

graphics/lightbulb_icon.gif

Almost every formatting option is conditional. To determine which ones are conditional look for the x+2 button next to the option in the Formatting Editor dialogs.

If a formatting option has already been set to a conditional format, the button will appear with red text. Otherwise, it will appear as blue text.


Apply Formatting from Another Field

One of the simplest examples of using one field to format another is to apply an email or hyperlink to a non-Internet field. In the Xtreme example, management would like to replace the Crystal Decisions hyperlink with the customer's email contact field.

  1. Use Chap 13_4.rpt as a starting point. Right-click on the Group Name field and choose Format Field. Select the Hyperlink tab. Change the hyperlink type to Email Address.

  2. Create the Conditional Formatting Formula. Click the x+2 button to bring up the Format Formula Editor dialog. Because this is an email address, the Mailto: Internet keyword will need to be added to the email address. Input the following into the Editor dialog 'mailto:' + {Customer.E-mail}. Then choose the Save and Close button. Notice that the button on the Hyperlinks tab has changed to red. Click OK.

  3. Test the email link. Select the field again and notice that the email dialog appears instead of the Web browser and that the email address is different for each company.

  4. Save the report as chap13_5.rpt.

graphics/lightbulb_icon.gif

The Formula Workshop can be used with Formatting Formulas as well. In fact, it can do something quite amazing. Dragging and dropping formatting formulas from one object to another in the workshop group tree automatically applies the dragged formulas to the new report object. This should increase the productivity of formatting as well.




Sams Teach Yourself Crystal Reports 9 in 24 Hours
Sams Teach Yourself Crystal Reports 9 in 24 Hours
ISBN: B003D7JUVW
EAN: N/A
Year: 2005
Pages: 230

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