Link to home
Start Free TrialLog in
Avatar of MidWestGirl
MidWestGirl

asked on

Crystal Reports 2008 String formatting question

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},", " ,"," )



ASKER CERTIFIED SOLUTION
Avatar of Ido Millet
Ido Millet
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of James0628
James0628

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
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