Conditionally change label text

This procedure demonstrates how to change label text if a certain condition is met.

  1. Create a new report.
  2. In the Field List, right-click any item inside the new dataset, and click Add Calculated Field.
    Calculate field
  3. In the Property Grid, set the field's Field Type property to String, then click the browse button (...) for the Expression property.
    This opens the Expression Editor dialog box.
    Change text
  4. In the Expression Editor dialog box, define the required condition for the calculated field, and then click OK.
    Example For example, Iif([UnitsOnOrder] == 0, 'None', [UnitsOnOrder], which specifies that if the UnitsOnOrder data field's value is equal to 0, the appropriate control's text will be replaced with None.
  5. Drag the required data fields (and the created calculated field as well) from the Field List onto the report's Detail band.
    Change text

    For m more information, see Report bands.

  6. The report is now ready. Switch to the Preview tab, and view the result.
    Change text