Want certain display with multiple iif's

jhillbh

New member
Local time
Today, 10:41
Joined
Sep 4, 2007
Messages
3
Hello, I have the following code in a report;

=IIf([direct discount:]>0,"Direct Discount - " & [Direct Discount:] & "
" & IIf([Interline discount:]>0,"Interline Discount - " & [Interline Discount:] & "
" & IIf([Direct Minimum:]>0,"Direct Minimum - " & [Direct Minimum:] & "
" & IIf([Interline Minimum:]>0,"Interline Minimum - " & [Interline Minimum:] & "
" & IIf(IsNull([fak])," ","FAK - " & [fak])))))

It works fine if i have something in each field before the other, but i just noticed that if i don't have a discount in Direct Discount, the rest don't show up in my text box. Am i way off in my coding or am i just missing something small.
Below,If i have 44 in each discount or minimum i get; but if i'm missing direct discount i get nothing returned.
Direct Discount - 44
Interline Discount - 44
Direct Minimum - 44
Interline Minimum - 44
Thanks in advance.
 
Unless my eyes deceive me, you have no false argument specified for the main function, which would explain that behavior.
 
You're forgetting the false part.

IIf(expression, true, false)

I'm guessing that if your value is not > 0, that it's Null or negative, in which case in your code nothing is done to that part.

Try this:

IIf([direct discount] > 0, "Direct Discount - " & [Direct Discount], "Direct Discount - None") & IIf([Interline Discount] > 0, "Interline Discount - " & [Interline Discount], "Interline Discount - None"), etc.
 
yes, the false part for each iif is missing...

and when the code first iif evaluates to false (which is missing), the if exits and returns nothing.
 
Do I need to promulgate the usage of the Switch function again or would that be ostentatious? This is a perfect example of nested If statements gone wild. (We can't show you what these crazy if statements do on TV! We asked them to just evaluate something and come out with a true and a false part, but they had ideas of their own! Order now, and we'll send you two instances of crazy if statements gone wild for just $9.99!)

Maybe this is too much late night TV. ;)
 
Thanks all! Don't know what I was doing. Was just one of those days I guess.
 

Users who are viewing this thread

Back
Top Bottom