PDA

View Full Version : Replace Command in Crystal Reports 9


MEA
October 25th, 2004, 05:00 PM
I’m trying to replace state abbreviations with full names. A previous post suggested that I type the following:



Replace ({Name.STATE}, "AR", "Arkansas" );
Replace ({Name.STATE}, "AZ", "Arizona" );
Replace ({Name.STATE}, "CA", "California" );
Replace ({Name.STATE}, "CO", "Colorado" )



But when I do this I only get the last line of code entered. Meaning ‘Colorado’ is the only state abbreviation that is replaced.



Likewise, if I enter:


Replace ({Name.STATE}, "AR", "Arkansas" );
Replace ({Name.STATE}, "AZ", "Arizona" );
Replace ({Name.STATE}, "CA", "California")

‘California’ is the only state abbreviation to change.

I am entering this code into the “Use a Formula as Group Name” in the group expert. How do I get all the state abbreviations to change?

smurfy
October 26th, 2004, 07:48 AM
Hello MEA, welcome to the forum, thanks for using the search function.
My previous post was using CR 8.0. I can't imagine it wouldn't work in CR9 but the main difference is where we are entering the formula.
I suggested entering a formula field into the report data area, using the formula editor, this REPLACE function will work. If you are trying it to label the group in the group expert (which I have never used) it may not work the same. I'd need to do a little digging into the group expert if there is no way you can use the formula editor for the task you are trying to achieve.

MEA
October 26th, 2004, 05:38 PM
Thanks for the reply smurfy, I've followed your directions as best as I can, and it doesn't seem to remedy the problem. Has anyone else ever seen this? Or does anyone else have CR9 to try to confirm my problem?

Thanks,
MEA

smurfy
October 27th, 2004, 01:06 AM
Sorry MEA, this works in 8.0 in the group expert formula as well (just tested it). We've gone straight from 8.0 to Crystal Enterprise so I don't have access to 9.0 to test.

I've just noticed you haven't bracketed the entire REPLACE function as I suggested to the previous poster.

(Replace ({Name.STATE}, "AR", "Arkansas" ));
(Replace ({Name.STATE}, "AZ", "Arizona" ));
(Replace ({Name.STATE}, "CA", "California" ));
(Replace ({Name.STATE}, "CO", "Colorado" ))


Have you had a look in CR9 Help at the REPLACE function to see if the syntax may have changed slightly?