Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Still about IF Else Then Post Reply Post New Topic
Author Message
Mari
Newbie
Newbie
Avatar

Joined: 30 Mar 2010
Location: France
Online Status: Offline
Posts: 4
Quote Mari Replybullet Topic: Still about IF Else Then
    Posted: 30 Mar 2010 at 9:08pm

Hello

I'm fighting against this code for days and I cannot make it works. I'm creating a formula that should return a different text, depending on content of different fields, but it seems to be stopping before the first ELSE. These the codes I tried so far:

1)

If {TAB_A.QTD} <= {TAB_B.TOTAL}

    then (If {TAB_A.TBR} = "x" Then "TBR"

    else (If { TAB_A.OL } = "x" Then "OL"

                else (If { TAB_A.CIA} = "x" Then "CIA")))

2)

if {TAB_A.QTD}<={TAB_B.TOTAL} and {TAB_A.TBR}="x" then TBR'

else if {TAB_A.QTD}<={TAB_B.TOTAL} } and {TAB_A.OL}="x" then ‘OL’

else if {TAB_A.QTD}<={TAB_B.TOTAL} and {TAB_A.CIA}="x" then 'CIA'

Thank you all for any help.
 
Mari
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 31 Mar 2010 at 5:21am
It appears both if statements are functionly (sp?) the same.  The only thing I can suggest is commenting out parts of the if statement (without breaking the syntax) and seeing if you can determine where the issue is.  Of course without knowing the data, I am not sure what results to expect.
Also I avoid using parenthesis (too easy to group improperly).
IP IP Logged
flanman
Senior Member
Senior Member
Avatar

Joined: 04 Nov 2009
Online Status: Offline
Posts: 123
Quote flanman Replybullet Posted: 31 Mar 2010 at 12:05pm
When you are creating the formula are you getting an error? If so what is the error and where is the formula editor point?
IP IP Logged
Mari
Newbie
Newbie
Avatar

Joined: 30 Mar 2010
Location: France
Online Status: Offline
Posts: 4
Quote Mari Replybullet Posted: 06 Apr 2010 at 11:18pm

Thank you for the answer and yes, the both statements are the same. I just tried to show the different ways I wrote them.

Here is the logic I need to test:
 
If TableA.Quantity <= TableB.Total
Then If TableA.FieldA = 'x' Then "A"
Else If TableA.FiedlB = 'x'' Then "B"
Else If TableA.FieldC = 'x' Then "C"
 
The issue is, all the examples I found regarding If Else in Crystal test the same field, and in my case, after testing the first condition(first IF), I need to test 3 different fields.
Thank you in advance for any help.
 
Mari
IP IP Logged
Mari
Newbie
Newbie
Avatar

Joined: 30 Mar 2010
Location: France
Online Status: Offline
Posts: 4
Quote Mari Replybullet Posted: 06 Apr 2010 at 11:29pm

Hello

I don't get any error. When runnoing the report, the first and second conditions are tested and they work fine. So, the report shows the text "A", as it should, but never shows the text "B" or "C", despite the data fits the conditions for the third and forth tests. It seems to me that Crystal, somehow, is not testing from the first ELSE on.
Regarding the editor point, this is my first report with Crystal and I'm not sure how to use that.
 
Thank you.
 
Mari
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 07 Apr 2010 at 2:49am
since youa re evaluating different fields you likely have NULLS. try changing the formula to 'Use default values for Nulls'
 
IP IP Logged
Mari
Newbie
Newbie
Avatar

Joined: 30 Mar 2010
Location: France
Online Status: Offline
Posts: 4
Quote Mari Replybullet Posted: 07 Apr 2010 at 3:40am

GREAT!!! That's it! Now it works perfectly.

Thank you very much! Thumbs%20Up

 
Mari
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.016 seconds.