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

Replacing a field with two combined fields

Status
Not open for further replies.

CRadel

Technical User
Jun 3, 2011
15
US
Hi. I'm a fairly inexperienced Crystal reports User (version 8.5), but I'm hoping someone can help me in somewhat non-technical language.

My data source has two fields (name, donor ID) that I want to appear as one in my report. Ideally it would look like: "Name, (ID Number)" or "Joe Smith, 1345"

What is the best way to either replace one field with the two combined, OR to include the two fields, but have them print as in the example above?

If it matters, the Donor ID is most-often just a number, but sometimes it is a combination of Numbers & letters, and in a few odd instances, just letters.

Thanks in advance!

Carol
















 
create a formula substituting your database fields for my examples.
//{@combined}
stringvar nm;
numbervar id;

if isnull({table.Name}) or TRIM({table.Name})=""
then nm := " "
else nm := {table.Name};

if isnull({table.ID}) or TRIM({table.ID})=""
then id := " "
else id := {table.ID};

nm & ", (" & id & ")"


you can do it without the variables, but i have found that it is easier for me this way.
In an ideal world there would be no null values for name or ID and you could just use: {table.Name} & ", (" & {table.ID} & ")"

 
Thanks. Where do I go exactly to enter this formula?
 
I would just create a formula in the field explorer->formula->new like fisheromacse's second one:

{table.Name} & ", (" & {table.ID} & ")"

Even if you needed to check for nulls, there is no need to use variables, which I think makes it overly complex for a beginning report writer.

-LB
 
Thank you both! It works! I did opt for the simpler version...worked perfectly!

Carol
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top