Skip to main content

Use Sub-bands to Show a Report Band Conditionally

This topic describes how to use sub-bands to display different content based on a specific condition.

The report created in this tutorial contains two sub-bands of the DetailBand with different sets of report controls. One sub-band displays data when the customer’s Contact Title is `Owner’; another sub-band displays data for other cases.

Conditionally Change Sub-band Visibility

Do the following to create a report with conditionally visible sub-bands:

  1. Use the Report Wizard to create a Table report bound to the Customers table of the Sample Northwind Database.

  2. Add two sub-bands to the Detail band:

    Conditionally Change Sub-band Visibility - Add Sub-bands

  3. Copy the data-bound table to the sub-bands. Delete the cells bound to the Address, City, Region, and Country fields from SubBand2. Delete the data-bound table from the Detail band:

    Conditionally Change Sub-band Visibility with Fields

  4. Select SubBand1 and click the f button to invoke the Expression Editor. Specify the following expression for the Visible property:

    [ContactTitle] == 'Owner'
    

    Conditionally Change Sub-band Visibility - First Sub-band

  5. Select SubBand2 and click the f button to invoke the Expression Editor. Specify the following expression for the Visible property:

    [ContactTitle] != 'Owner'
    

    Conditionally Change Sub-band Visibility - Second Sub-band

  6. Switch to the Preview window and observe the result:

    Conditionally Change Sub-band Visibility - Result