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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If then must contain data instead of = data

Status
Not open for further replies.

wendle

Technical User
Jun 4, 2002
3
US
I would like to use an if then statement to color code certain words found in my data field. For example:
If the field contains the word "convention", color it red.
This is the expression that I tried:

If {Conthist.ref} = "*convention*" then crTeal

I thought by putting the asteriks around the word convention it would change it to mean that the field must contain the word instead of exactly matching the word.

Any suggestions?
 
Try using the "InStr" function to extract the word 'convention' or 'convent'
 
InStr(StringtobeSearched,Substring) returns the integer of the character number where the string is found, or zero if it is not found. So:

if InStr({Conhist.ref},"Convention")>0 then CrTeal else DefaultAttribute

would be the way to conditionally color your data. Software Support for Macola, Crystal Reports and Goldmine
dgilsdorf@mchsi.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top