Conditionally hide bands
This procedure describes the steps to conditionally hide bands.
In this example, we will hide the Group Header and Detail bands when a grouping field meets a certain condition. Note that this procedure does not use scripts to accomplish this task.
For more information, see Report bands.
- Create a new report.
-
Add a Group Header band to the report.
To do this, right-click anywhere over the report's surface, and click.
-
Drag a field that will be used as a grouping criteria from the Field
List onto the created GroupHeader1
band.
-
Click the Smart tag of the GroupHeader1 band, and in the
invoked actions list, click the browse button (...) in
the Group Fields section.
This opens the GroupField Collection Editor dialog box.
- Click Add, to add a new grouping field, and set its Field Name property to the required field.
- Click OK to apply the settings and close the dialog box.
-
Drag fields representing the general report's data onto the report's
Detail band.
- Select the Group Header band's strip, then in the Property Grid, click the Formatting Rules browse button.
- In the Formatting Rules Editor, click the Edit Rule Sheet button.
- In the Formatting Rule Sheet Editor, click the Add button, to create a new rule.
- Set the new properties Visible property to No, and for the Condition property, click the browse button (...).
- Construct the required Boolean expression to be met (for example, [ShipCountry] == 'Argentina'). Then click OK and Close to close the Formatting Rule Sheet Editor.
-
In the Formatting Rules Editor, activate the new rule by
moving it to the Applied Rules box.
Repeat this step for the report's Detail band (click its Formatting Rules property's ellipsis button, and in the invoked dialog, apply the same rule to this band). If you do not do this, the Group Header band will not be displayed when the rule's condition is met while the detailed section of this group will still be visible.
-
Switch to the Preview Tab to view the result.
In the figure, you can see that there is no Argentina section in the report, while it's the first record in our database. So, the conditional formatting was applied properly.