Annette Wilson, MSIS
asked on
Crystal Reports - If left 4 equal then print text
Hi,
I see that there is a string function in Crystal Reports that allows me to replace a string is follows:
a:=replace(a,"EAN", "NEW");
I want to say, If the first four character in a string equals "SAMP" then replace with "NEWSAMP".
How do it do this in Crystal Reports?
I see that there is a string function in Crystal Reports that allows me to replace a string is follows:
a:=replace(a,"EAN", "NEW");
I want to say, If the first four character in a string equals "SAMP" then replace with "NEWSAMP".
How do it do this in Crystal Reports?
ASKER
mlmcc,
Thank you for responding. In your solution, where is the field value evaluated?
If Left 4 of {FIELD} = "SAMP" then string = "NEW"
Thank you for responding. In your solution, where is the field value evaluated?
If Left 4 of {FIELD} = "SAMP" then string = "NEW"
Is a a variabloe or a field?
If it is a field you can't change field values.
mlmcc
If it is a field you can't change field values.
mlmcc
ASKER
Can I have a function that reads the first 4 characters in the field and when and display text according to the first 4 characters.
I'm not trying to change field values, just make sure the when a field has a certain first 4 characters that the report displays text.
I am able to do this in other reporting programs with a StringIF function.
Is there a StringIF in Crystal Reports?
I'm not trying to change field values, just make sure the when a field has a certain first 4 characters that the report displays text.
I am able to do this in other reporting programs with a StringIF function.
Is there a StringIF in Crystal Reports?
There is no stringIf.
You can use
If Left({YourFIeld},4) = "SAMP" then
"NEW"
Else if Left({YourFIeld},4) = "STAN" then
"OLD"
etc
mlmcc
You can use
If Left({YourFIeld},4) = "SAMP" then
"NEW"
Else if Left({YourFIeld},4) = "STAN" then
"OLD"
etc
mlmcc
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try this
If UpperCase(Left({Field},4)) = "RNDT" then
"RUN CONTROLLED"
Else if UpperCase(Left({Field},3)) = "TAC" then
"TACT CONTROLLED"
Else
{Field}
mlmcc
If UpperCase(Left({Field},4))
"RUN CONTROLLED"
Else if UpperCase(Left({Field},3))
"TACT CONTROLLED"
Else
{Field}
mlmcc
Did you need the formula?
mlmcc
mlmcc
ASKER
Thank you very much. This worked. I traced the data in the database and the data was never populated. Once I took care of the correct query, everything worked just fine.
If Left({a,4) = "SAMP" then
a := "NEW" & a;
mlmcc