Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Crystal Reports - If left 4 equal then print text

Posted on 2013-05-14
9
Medium Priority
?
767 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
Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 

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 Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Hello, In my precious Article  (http://www.experts-exchange.com/Database/Reporting/A_15280-Create-Project-in-Microstrategy-Part-I.html)we saw the Configuration part for Microstrategy which included Metadata Creation and DataSource Preparation as …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

604 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