Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: if -then statement not showing in report. Post Reply Post New Topic
<< Prev Page  of 2
Author Message
freakingeek
Newbie
Newbie


Joined: 27 Feb 2014
Location: United States
Online Status: Offline
Posts: 7
Quote freakingeek Replybullet Posted: 28 Feb 2014 at 7:07am
I tried :
stringvar gender_string;

if {DDB_PAT_BASE.Gender}=1 then gender_string = "Male"
else if {DDB_PAT_BASE.Gender}=2 then gender_string = "Female"
else if {DDB_PAT_BASE.Gender}=3 then gender_string = "Other"
else if {DDB_PAT_BASE.Gender}=4 then gender_string = "Unknown";

gender_string

Unfortunatly the results are the same. The gender field in the report still only shows the numbers assigned the to gender.

IP IP Logged
freakingeek
Newbie
Newbie


Joined: 27 Feb 2014
Location: United States
Online Status: Offline
Posts: 7
Quote freakingeek Replybullet Posted: 28 Feb 2014 at 7:18am
To answer an earlier question, I am not using an existing report. I created this report and I used a formula from another report that is using the same
"DDB_PAT_BASE" table.  
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 28 Feb 2014 at 7:59am
Just to be clear.
When you create a formula field in the Field Explorer it does not alter the existing data. It is not like an update script. The formula field itself can be placed on the report canvas to display the result of the formula. At no point does any formula in crystal alter the source data.
SO if you place, on the detail section the original field "DDB_PAT_BASE.Gender" and the next to it the Formula field that references it you should see the the origianl numeric value with ther translation into text next to it.
If you place them side by side what is the result?
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 28 Feb 2014 at 8:04am
just as a note:
stringvar gender_string;

if {DDB_PAT_BASE.Gender}=1 then gender_string = "Male"
else if {DDB_PAT_BASE.Gender}=2 then gender_string = "Female"
else if {DDB_PAT_BASE.Gender}=3 then gender_string = "Other"
else if {DDB_PAT_BASE.Gender}=4 then gender_string = "Unknown";

gender_string

is missing the assignment operator...all the = should be :=

and as DBlank said, the gender field will always be the value from the database...only the formula will be different, because, again as stated, the data is not being changed, you are just changing how it is displayed with the formula
IP IP Logged
freakingeek
Newbie
Newbie


Joined: 27 Feb 2014
Location: United States
Online Status: Offline
Posts: 7
Quote freakingeek Replybullet Posted: 28 Feb 2014 at 8:29am
I am not trying to change the results of the information.
For example, changing a 1 to a 2. I am simply trying change the numeric output to show as something other then a numeric value. So one will only show as male, two will only show as female.

It sounds like I am not getting the formula to show on the table. Doesn't the formula automatically present itself on the report once it's in a readable format? If not how do I add it to the report?
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 28 Feb 2014 at 8:31am
you need to place the formula on the report.

we realize that all you want to do is to display male instead of 1.

the logic that has been posted would seem to this, so if the formula has been placed on the report where you want to display it (which we assume you have done) and it is not displaying the correct results...then we have been giving suggestions on how to correct the logic or how to debug your logic.

it also sounded from one of the posts that you thought the formula would update the data in the field so that it would display as desired (male instead of 1), which is not the case.

just trying to help

Edited by lockwelle - 28 Feb 2014 at 8:35am
IP IP Logged
freakingeek
Newbie
Newbie


Joined: 27 Feb 2014
Location: United States
Online Status: Offline
Posts: 7
Quote freakingeek Replybullet Posted: 28 Feb 2014 at 9:18am
Got it. I wasn't dragging the formula into report.
Thank you!
IP IP Logged
<< Prev Page  of 2
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.018 seconds.