|
Another way that you can filter, control, or refine what the user of a report sees is to suppress (meaning to hide) data and text objects. You can suppress items based on whether a condition is true or unconditionally suppress it at all times. There are several places in Crystal Reports to suppress information. In some cases your knowledge of formula language will be required; in others, you just need to enable a check box. Let’s take a look at how to hide individual field objects, text objects, and embedded fields within text objects as well as how to hide entire sections.
The Format Editor can be used to enable the suppression of individual fields of data in several different scenarios:
Suppress unconditionally
Suppress if duplicated
Suppress conditionally based on a formula
Any field can be unconditionally suppressed using the Common tab of the Format Editor, shown in Figure 7.17. With the Suppress check box enabled, the field will be hidden at all times. This is particularly handy if you’re coding temporary fields or formulas that are needed for interim calculations whose results do not need to appear in the actual report.
Figure 7.17. Unconditionally suppress fields
At the bottom of Figure 7.17, the Suppress If Duplicated option is visible. When this option is enabled, if the field encounters a value that it has had in a previous record, the value will not be printed in the report or shown onscreen. Space is still reserved for the suppressed duplicate value and an empty space will be substituted.
The dialog shown in Figure 7.17 can also be used to conditionally suppress a field by writing a formula. To the far right of the Suppress check box and on the same horizontal line, there is a Formula button that you can click to open the Formula Workshop. Coding a condition in the editing area that will evaluate for each record in the database will suppress the field when the condition is true. Crystal will not display the value for the field; however, the space allocated for the field will remain visible. An example of a formula to conditionally suppress a field is shown here:
If {Resorts.PurchasePrice} < 100000 Then formula = True 'suppress the value Else formula = False 'do not suppress it End If
Alternatively, you can code just the condition portion of the statement, which will directly return a TRUE or FALSE value to suppress the field:
{Resorts.PurchasePrice} < 100000
If the field exists in a section by itself and you do not want to see the empty space left by suppressing the field, you can suppress the entire section.
If the field being suppressed is a number field, you can apply an additional level of suppression by hiding the number only if the value is zero. Figure 7.18 shows this option.
Figure 7.18. Suppress zero values
Accessing this option is a little tricky in the interface, so here’s how to do it:
Select the field in the Design pane.
Open the Format Editor for the field by right-clicking and choosing the Format Field menu option, or choose Format > Format Field.
Click the Customize button.
On the Number tab, select the Suppress If Zero option.
Date fields can be formatted to suppress dates unconditionally, suppress a date value if it duplicates a date value in a previous record, or suppress conditionally based on a formula. Use the Common tab on the Format Editor for all of these actions.
The Format Editor can be used to suppress text objects as well as field objects. To open the Format Editor, select the text object and then right-click it and choose the Format Text menu option, or choose Format > Format Text from the main menu. The Common tab for a text object is very similar to the Common tab for field objects, containing the same first three suppress options plus a fourth option specific to text objects:
Suppress unconditionally
Suppress if duplicated
Suppress conditionally based on a formula
Suppress embedded field blank lines
You can refer to the discussion of unconditionally suppressing, suppressing on duplicate values, and suppressing conditionally in the “Field Objects” section above. Let’s look at the new option, suppressing on embedded field blank lines.
Oftentimes you’ll embed a field or series of fields inside a text box. For instance, when you build a name and address block for a form letter, you might put all the fields inside a text object so that you can format them as a single unit. This technique is shown in Figure 7.19.
Figure 7.19. Text object with embedded fields
Since a text object of this type consists of several other fields and sometimes typed text, you may want to hide parts of the text object but not the entire thing. Anything placed on its own line within a text object can be hidden. In the example of the name and address block, if Address2 has no value and is on its own line, you can suppress the line using the Suppress Embedded Field Blank Lines option on the Common tab of the Format Editor. This option is shown in Figure 7.20.
Figure 7.20. Suppressing embedded blank fields
With this option enabled, when no value is retrieved from the database for a field embedded in the text object, the blank line that would normally be left as a placeholder will be suppressed and no space will be reserved for the embedded field.
Sections act as a container for report elements. You can hide sections to force an entire container of elements to be hidden at any given time. Like fields, sections can be suppressed conditionally, unconditionally, or not at all. A section can be suppressed in the following ways:
Suppress a section initially and allow drill-down later
Suppress and do not allow drill-down (unconditional and conditional)
Suppress blank sections
Suppress and allow drill-down Drill-down refers to the capability to click a topic and open the detail data for that topic in a separate window tab. For instance, if you click a grand total, you can drill down and see the detail data that contributed to the grand total. Hide (Drill-Down OK) is a section property that you set by using either the Section Editor or by right-clicking the gray section title in Design mode and choosing the Hide (Drill-Down OK) option from the menu, as shown in Figure 7.21. You’ll know a section is drill-down-capable by the change in the cursor; a magnifying glass appears over the top of drill-down-capable areas.
Figure 7.21. Section
Suppress and do not allow drill-down In Figure 7.21 the section option to Suppress (No Drill-Down) is visible. When you select this menu option, the entire section, including all report elements, is suppressed completely and not visible at any time. When used from the submenu, this option is unconditional. When you select it from the Section Editor, you can click a Formula button to conditionally enable or disable the option to suppress and not allow drill-down. For more information on using the Section Editor, refer to Chapter 8, “Customizing Sections.”
Suppress a blank section A blank section is one that does not contain any text objects or fields that contain values. The Section Editor contains a check box option to Suppress Blank Section, which can be enabled either unconditionally so that the section will always be suppressed when blank or conditionally based on a formula value that, when true, will suppress a blank section.
Use of content on this site is expressly subject to the restrictions set forth in the Membership Agreement | |
Conello © 2000-2003 Feedback |