Crystal Reports & SQL Reporting Services Training Consultants
Account Log in:
Username:
Password:
Freedom is instantaneous the moment we accept things as they are
 
Karen Maezen Miller
Institute of IT Trainers - Freelance Trainer of the Year 2006 & 2009
Liverpool Business Connect Member
  Maximum Impact Solutions Limited - Reporting Solutions, Creating Answers
Reporting Solutions - Creating Answers, Crystal Reports, Dashboarding (Xcelsius) & SQL Reporting Services

The Maximum Impact Solutions Blog Feed ME!!!!

04
September

How Do I Change the Font Colour of a Field based on a String it Contains in Crystal Reports 2008?

During a recent crystal reports 2008 consultancy project I was asked "How can I change the font colour of a field, if it contained a certain string within it?"

Solution:

To achieve this on needs to use the Crystal Reports string function InStr.

The formula is as follows:

If InStr({Tablename.Fieldname},  "SearchString",1) <> 0 Then CrAqua Else CrNavy

The formula would be attached via the conditional formatting button of the Font Color option for the field

If you have any questions, leave us a comment below, or need any assistance, please do not hesitate to Contact Us


1

Sky

06
October
What if I need to do two colors based on two search terms? If InStr({RMS_Object.Object_Description},"WS",1) <> 0 Then crRed If InStr({RMS_Object.Object_Description},"DV",1) <> 0 Then crBlue Else crBlack I tried connecting them by or but it wants a boolean... which, um, "OR" is. I thought.
2

Julia

06
October
There's a slight error in your formula. You're correct in using a nested IF statement: If InStr({RMS_Object.Object_Description},"WS",1) <> 0 Then crRed Else If InStr({RMS_Object.Object_Description},"DV",1) <> 0 Then crBlue Else crBlack
3

Julia

13
October
There's a slight error in your formula. You're correct in using a nested IF statement: If InStr({RMS_Object.Object_Description},"WS",1) <> 0 Then crRed Else If InStr({RMS_Object.Object_Description},"DV",1) <> 0 Then crBlue Else crBlack

MAKE A COMMENT

Name *

Email Address *

Comment *

To prove you are human what is:

72 + 20 =