This tutorial demonstrates how to change a label's text if a certain condition is met.
To conditionally format a label's text at design time, follow the instructions below.
-
To create a calculated field, in the Field List, right-click any item inside the created dataset, and on the invoked menu, choose Add Calculated Field.
-
Now, in the Property Grid, set the field's Field Typeproperty to String. Then, locate its Expressionproperty and click its ellipsis button. The Expression Editorwill appear.
In this dialog, define the required condition for the calculated field (e.g. Iif([UnitsOnOrder] == 0, 'None', [UnitsOnOrder]), which means that if the UnitsOnOrderdata field's value is equal to 0, the appropriate control's text will be replaced with None).
To close the dialog, click OK.
-
Finally, drop the required data fields (and the created calculated field as well) from the Field List onto the report's Detailband.
The report is now ready. Switch to the Preview Tab, and view the result.
See Also