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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple if-then-else statements

Status
Not open for further replies.

nosoyaguru

Programmer
Nov 30, 2005
5
US
Why is it that the statement below only works for the first IF condition, I can switch the statements around but only the first condition works:
if ({GUARANTEE_REPORT.PLUS_CERTIFIED_AMOUNT} > 0)
then "PLUS"
Else
if ({GUARANTEE_REPORT.SUB_CERTIFIED_AMOUNT} > 0)
then "SUB"
else
if ({GUARANTEE_REPORT.UNSUB_CERTIFIED_AMOUNT} > 0)
then "UNSUB"
else
if ({GUARANTEE_REPORT.UNSUB_CERTIFIED_AMOUNT} > 0 and
{GUARANTEE_REPORT.SUB_CERTIFIED_AMOUNT} > 0)
then "COMB";

There are no syntax errors on Crystal 9.2 and Oracle 10g.

Any help will be appreciated.
 
Hi,
Try testing for the "COMB" First..

Are there any cases where BOTH PLUS_CERTIFIED_AMOUNT and Either SUB_ or UBSUB_ are > 0?

If so, it becomes more complex..

( also be sure to check first for NULLs in each field)



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Thanks for the prompt reply. I've tried your suggestion, same results.

And no, there are no cases where both PLUS & SUB or UNSUB amounts are present, its either PLUS or SUB, or UNSUB, but sometimes there are SUB & UNSUB amounts.

It seems so simple (this is common programming code in other languages). I'll keep trying.
 
Sorry, it does work, but I don't know how since when I first re-coded the statement it didn't. I closed CR and re-started the report, then it worked!!!

Again, thanks, I think that cheking for nulls and greater than zeroes is what did it.
 
If you lay these out in the detail section, you will see where there is overlap. An if-then formula will stop evaluating a specific row if the row meets the first criterion in the if-then.

If you want a result where the row is evaluated multiple times to test all criteria, you will need to take a different approach, maybe evaluating each criterion separately and assigning different numeric values and then determining text results by different sums formed by the component values.

-LB
 

Thanks, that is an excellent idea.

I was begining to think in that direction but I thought I should be able to get it to work in its initial code.

Assigning values to individual results maybe easier than compounding lots of IF statements.
 
I posted before I read your post saying that Turkbear's suggestion worked--if it works, no need to fix it!

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top