Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Help Please: How to create a "variable field" Post Reply Post New Topic
Author Message
Michalec
Newbie
Newbie


Joined: 02 Jul 2009
Location: United States
Online Status: Offline
Posts: 2
Quote Michalec Replybullet Topic: Help Please: How to create a "variable field"
    Posted: 02 Jul 2009 at 9:11am
Hello

I am a very basic Crystal Reports user and I need to do something that seems like it would be easy.  I can't figure out how to do it however.

I have a field in the database that has a code in it.  I need to take that code and use it in another created field so that has a translation for the code is displayed when the report is exported.  Here is what I have:

Field1 = Field in the database, has a code as text
Field2 = Created field that is not in the database and is variable

What I want to do:

If {table.Field1} = "A172" then {Field2} = "dogs"
else if {table.Field1} = "R175" then {Field2} = "cats"
etc. etc.

I just do not know how to create Field2 and I do not know where to put the code to do this.  I am not even sure if this is the best way to do this or if it is even doable.

Any help would be greatly appreciated.

Thank You

IP IP Logged
JohnT
Groupie
Groupie
Avatar

Joined: 20 Jan 2008
Online Status: Offline
Posts: 92
Quote JohnT Replybullet Posted: 02 Jul 2009 at 2:02pm
Right click on the formula field shown in your field explorer.  Create a new formula and call it field2.  Click on editor.  Use the editor to create your new formula.  You can use the functions, report fields and operators to build your new formula or just type it in.  When you are finished, click on save and close.  If everything is correct, you will return to your report.  If not, you will see error messages.  Use field2 in your report as needed.   
 
Your syntax would be
 
If {table.Field1} = "A172" then  "dogs"
else
    if {table.Field1} = "R175"  then "cats"
 
This would set field2 to either "dogs" or "cats"
 
Hope this helps.  Good luck.
IP IP Logged
Michalec
Newbie
Newbie


Joined: 02 Jul 2009
Location: United States
Online Status: Offline
Posts: 2
Quote Michalec Replybullet Posted: 02 Jul 2009 at 3:18pm
Thank you very much I think that is exactly what I needed. 


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.031 seconds.