Solved

Crystal Reports - If left 4 equal then print text

Posted on 2013-05-14
9
675 Views
Last Modified: 2013-06-12
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?
0
Comment
Question by:Annette Wilson, MSIS
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 39165921
StringVar a;
If Left({a,4) = "SAMP" then
    a := "NEW" & a;

mlmcc
0
 

Author Comment

by:Annette Wilson, MSIS
ID: 39165981
mlmcc,

Thank you for responding.  In your solution, where is the field value evaluated?

If Left 4 of {FIELD} = "SAMP" then string = "NEW"
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 39165996
Is a a variabloe or a field?

If it is a field you can't change field values.

mlmcc
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Annette Wilson, MSIS
ID: 39166551
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?
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 39166658
There is no stringIf.

You can use

If Left({YourFIeld},4) = "SAMP" then
    "NEW"
Else if Left({YourFIeld},4) = "STAN" then
    "OLD"
etc

mlmcc
0
 

Accepted Solution

by:
Annette Wilson, MSIS earned 0 total points
ID: 39229286
I tried the following and nothing comes up.

If Left({Field},4)="RNDT" then "RUN CONTROLLED"
Else if Left({Field},3)="TAC" then "TACT CONTROLLED"


Should I declare text as a string then evaluate?  If so, how would I write this in crystal reports?
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 39229942
Try this

If UpperCase(Left({Field},4)) = "RNDT" then
      "RUN CONTROLLED"
Else if UpperCase(Left({Field},3)) = "TAC" then
      "TACT CONTROLLED"
Else
      {Field}

mlmcc
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 39230448
Did you need the formula?

mlmcc
0
 

Author Closing Comment

by:Annette Wilson, MSIS
ID: 39240444
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.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need to learn crystal reports 7 94
business objects to connect to MSSQL 6 111
Crystal Reports Version 7 4 48
Crystal Report - Charts 4 50
I recently went through setting up a JasperReports Server using the AWS EC2 instance, and this article will cover some basic administration tasks I had to perform.
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.
Suggested Courses

739 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