Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditional Formatting of Strings 1

Status
Not open for further replies.

JustineB

Programmer
Mar 30, 2001
165
GB
Hi!
I have an annoying problem. I need to apply a background colour to all Customers whose name contains the letter "e" and I just can't figure out how to do it.
Any ides??

Many thanks in advance
Justine.
 
Right click on the string field and click border and colors. Then click on the X-2 button to the right of Background Color and enter the following formula:
If InStr({stringfield},&quot;e&quot;)<>0 then gray(or whatever color you desire) else nocolor.

InStr returns the number of the first appearance of the second string in the first string, or zero if the string is not found. You can also make the second argument a multi-letter string. Software Support for Sage Mas90, Macola, Crystal Reports, Goldmine and MS Office
 
Thanks so much - it was the <>0 that I was missing. Could you explain why I need this? I kept getting an error = &quot;Formula result must be a number&quot;, but was unsure of how to workaround it!
 
the InStr function returns a number so you must have a boolean that has a number in it. It is similar to a type mismatch error. Imagine a formula {Datefield}=&quot;ABC&quot;. You would get an error. Software Support for Sage Mas90, Macola, Crystal Reports, Goldmine and MS Office
 
Justine:

Some formulas require the use of If-then-else (eg. background color, borders etc.)and some just require a statement (eg. conditional suppress)

In looking at the different cases...where there is more than one choice an if-then-else is required...but in suppress there is only the one choice (ie. to suppress the field)

Also I noted in earlier versions (not sure that it applies in 8+) Not only did you have to use this formula but also you had to check off the box with a selection. With the conditional suppress you didn't have to check the box...you just had to enter the formula

not sure if this helps you....just one of the many Crystal oddities you learn with time :)
 
Thanks Ngolem!
I have been using Crystal reports for over five years, and am used to its oddities, but this one was a real headache! Nothing in the help about it either!
Thanks again for replying.
Justine
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top