Solved

Crystal Reports - If left 4 equal then print text

Posted on 2013-05-14
9
621 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
  • 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
 

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Hi, I am very much excited today since I'm going to share something very exciting Tool used for Analytical Reporting and that's nothing but MICROSTRATEGY. Actually there are lot of other tools available in the market for Reporting Such as Co…
How to increase the row limit in Jasper Server.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now