Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IIf function 1

Status
Not open for further replies.

mmt4331

Programmer
Dec 18, 2000
125
US

Can someone give me an example of the IIf function? How different is it from the If-then-else formula?


bigfuzzydog
 
it is basically a choice of actions


IFF({table.value} > 5,"return if true","return if false")
 
Someone correct me if I'm wrong but IIF usually processes the entire statement where as an If statement will stop processing once it reaches a True condition. Someone came up with a need for that - but I can't come up with an example.

DjangMan
 
If you are using the IsNull function to put in a default value for Nulls, you should use the If-Then-Else:

If IsNull({Customer.Postal Code})
then "ERROR"
else {Customer.Postal Code}

This will not work with IIF, because it chokes on the null value:

IIF(IsNull({Customer.Postal Code}),"ERROR",{Customer.Postal Code})

Ken Hamady, On-site/Phone Crystal Reports Training/Consulting
Quick Reference Guide to using Crystal in VB
 
Here's what Crystal says: "Typical uses:
IIF can be used as an alternative to the If/Then/Else control structure in some situations.
One situation where IIF may be better than a control structure is when writing record selection formulas so that they can be pushed down to the database server. See Switch (expr1, value1, expr2, value2, ..., exprN, valueN) for an example of the techniques involved."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top