?
Solved

Crystal Reports - If left 4 equal then print text

Posted on 2013-05-14
9
Medium Priority
?
715 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 101

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 101

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
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 

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 101

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 101

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 101

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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

762 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