Solved

Crystal Reports 2008 String formatting question

Posted on 2011-09-14
3
255 Views
Last Modified: 2012-05-12
I have a formula which I want to do 2 things to the same field in my database. It will only do the last statement. Is there a way to have it do both? I want it to remove the period after the initial in the name field and then remove the extra space between the first and last name. It removes the extra space but the period is still there. Here is the formula:  Thanks

WhilePrintingRecords;

// This one removes period after Middle Initial

Replace ({Projects.Resource Name},"." ,"" );


// This one removes the extra space between the
// first and last names

Replace ({Projects.Resource Name},", " ,"," )



0
Comment
Question by:MidWestGirl
3 Comments
 
LVL 22

Accepted Solution

by:
Ido Millet earned 500 total points
ID: 36539122
WhilePrintingRecords;
Replace(Replace ({Projects.Resource Name},"." ,"" ), ", " ,"," );

0
 
LVL 34

Expert Comment

by:James0628
ID: 36539161
A formula can only produce one value, so your formula does the first replace, and then the second, and you get the result from the second.  Combine them in one statement, as in Ido's post.

 James
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 36539269
As written, the formula produces 2 results.   The second result is the one that is displayed.

Replace does NOT change the string in the database just makes changes for in this case display.

You can use Ido's formula.

Another way is to use a local variable in the formula

WhilePrintingRecords;
Local StringVar strTemp;
// This one removes period after Middle Initial

strTemp := Replace ({Projects.Resource Name},"." ,"" );


// This one removes the extra space between the
// first and last names

strTemp  := Replace (strTemp ,", " ,"," );

strTemp

mlmcc

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now