Databases Reference
In-Depth Information
Figure 6-86
If the expression Fields!Quantity.Value < Fields!ReorderPoint.Value yields a True result
(where the Quantity is less than the ReorderPoint), the value “Red” is returned. Otherwise, the value
returned is “Black”. You'll see more examples using this function in Chapter 7.
In cases where an expression may return more than two states, IIF() functions may be nested to form
multiple branches of logic. In this example, three different conditions are tested:
=IIF( Fields!Quantity.Value < Fields!ReorderPoint.Value, “Red”,
IIF(Fields!ListPrice.Value > 100, “Blue”, “Black” ))
Let's analyze the logic: If Quantity is not less than the ReorderPoint, the third IIF() function argu-
ment is invoked. This contains a second IIF() function, which tests the ListPrice field value. If the value
is greater than 100, the value “Blue” is returned. Otherwise, the return value is “Black”.
Beyond the simplest of nested functions, expressions can be difficult to write and to maintain. In addi-
tion to decisions structures, common functions may be used to format the output, parse strings, and con-
vert data types. Count the opening and closing parentheses to make sure that they match. This is yet
another example of where writing this code in a Visual Basic class library or forms project is helpful
because of the built-in code-completion and integrated debugging tools. Consider using these other
functions in place of nested IIF() functions.
Search WWH ::




Custom Search