Conditionally Change a Label's Text
This tutorial demonstrates how to change a label's text if a certain condition is met. No scripts are required to accomplish this task.
To conditionally change a label's text, do the following.
- Create a new report and bind it to a data source.
Next, add a calculated field. To do this, in the Field List, right-click any item inside the created data source, and in the invoked context menu, select Add Calculated Field.
Select the calculated field, and in the Properties Panel, set its Field Type to String. Then, click the ellipsis button for the Expression property.
In the invoked Expression Editor, specify the required logical condition for the calculated field (e.g., Iif([UnitsOnOrder] == 0, 'None', [UnitsOnOrder]), which means that if the UnitsOnOrder data field's value is equal to 0, the control's text will be replaced with None).
To save the changes and close the dialog, click OK.
Finally, drop the required data fields and the created calculated field from the Field List onto the report's Detail band.
The report is now ready. Switch to the Print Preview tab and view the result.