Print Page | Close Window

Change Text color based on a character in string

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=22085
Printed Date: 29 Apr 2024 at 2:28am


Topic: Change Text color based on a character in string
Posted By: ibdavid
Subject: Change Text color based on a character in string
Date Posted: 14 Sep 2016 at 8:05am
I'm looking to change the color of text displayed, based on a special character being present. If, in this case a "?" is present in the text string, I'd like the text to be highlighted Red. I've tried various commands in the "display string" settings, however wildcards aren't recognized and I'm having difficulty making this happen. Thanks for any suggestions or guidance!



Replies:
Posted By: kevlray
Date Posted: 14 Sep 2016 at 11:02am
If you use the formula for the font (Format Field, Font).  I believe you can use special characters by recursing it by a \, (i.e., '\?').  Thus you can do something like this

if instring({somefield},'\?') > 0 then crred else crblack


Posted By: ibdavid
Date Posted: 19 Sep 2016 at 6:23am
Excellent, thank you! Trying now.



Print Page | Close Window