how do i put more IIf for one text box?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

i want to have an expression like =IIf[text17]=50,5,0 or =IIf[text17]=40,4,0
i.e. if text 17 gives me a value like 50 then the text box for which the
above if expression is should show me 5 and if it shows me 40 then to show me
4.
 
=IIF([text17] = 50,5,IIF([Text17] = 40, 4, 0))

I would not recommend nesting too many IIF statements, 2-3 at most. It
can get pretty messy.

Hope that helps!
 
i want to have an expression like =IIf[text17]=50,5,0 or =IIf[text17]=40,4,0
i.e. if text 17 gives me a value like 50 then the text box for which the
above if expression is should show me 5 and if it shows me 40 then to show me
4.

If you have multiple values - more than three or so, I'd say - then
there are two alternatives to using IIF. The Switch() function takes
any number of arguments in pairs, and goes through them left to right;
when it first finds a pair for which the first element is TRUE, it
returns the second member of that pair and quits. So you could have:

Expr1: Switch([Text17] = 50, 5, [Text17] = 40, 4, [Text17] = 30, 78,
[Text17] = 20, 18, <etc>)

Perhaps better, you could create a translation table with two fields -
one for the values like 50, 40, and so on, and the other for the
desired value. Join this table to your Query to look up the desired
value.

John W. Vinson[MVP]
 
Back
Top