Conditional Display of Field, Label and Value

You can easily hide or highlight the value of certain controls based on its own value or the value of another field in the database. The Formulas tab provides the ability to perform a comparison, and based on the result of comparison change the database field display.  This applies to any ‘literal’ control type, such as a FieldValue Literal, FieldLabel Literal, GEN:Literal or asp:literal control type.

Example #1

In this example, the OrderId is displayed in red if the UnitPrice is greater than 14 and the Quantity is less than 10.

= IF(UnitPrice > 14 AND Quantity <10, "<font color='red'>"+ OrderId + "</font>", OrderId.ToString())

Note: In order to see the text color changed to red, set the “HTML encode value” property for the OrderId control to False.

Example #2

This example displays the CustomerID in italics if the Shipped Date is greater than the Required Date:

= IF(ShippedDate > RequiredDate, "<i>" + CustomerID + "</i>", CustomerID)

Example #3

The following example shows the EmployeeID for all orders placed in the current week:

= IF(OrderDate >= StartOfCurrentWeek() AND OrderDate <= EndOfCurrentWeek(), "<font color='red'>" + EmployeeID + "</font>", EmployeeID.ToString())

Example #4

The following example ‘hides the field’ by displaying a blank string if the Order Amount is greater than 100:

= IF(OrderAmount > 100, ““, OrderAmount)

See Also

Common Formula Examples