Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Change Color of Text String Post Reply Post New Topic
Author Message
Peggy
Newbie
Newbie


Joined: 06 Jul 2007
Location: United States
Online Status: Offline
Posts: 2
Quote Peggy Replybullet Topic: Change Color of Text String
    Posted: 06 Jul 2007 at 12:29pm
Hi,
 
     I'm looking for a formula solution to dynamically change a portion of a text string.
 
     For example:  a string such as:
 
        Results:  OK                       {would remain normal color}
        
                           a string such as:
 
        Results:  Violation             {would have the word 'Violation' in red}
 
 Any help is appreciated!  Thanks.
Peggy
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 06 Jul 2007 at 1:09pm
Right-click on the field and select Format Field. Then click on the Font tab and click the Formula button next to the Color property. Enter a formula such as:
If {table.field} = "Violation" then
    crRed
else
    DefaultAttribute;

Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
Peggy
Newbie
Newbie


Joined: 06 Jul 2007
Location: United States
Online Status: Offline
Posts: 2
Quote Peggy Replybullet Posted: 06 Jul 2007 at 7:23pm
Brian - thanks for your response.   However, I'm looking to dynamically change a portion of a string.   For example a string such as:
 
My Name is Peggy.
 
I would like the words 'My Name is' to be black and the word 'Peggy' to be red as such: 
 
My Name is Peggy
 
The string field is one field.
I appreciate your input.
Thanks again.
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 07 Jul 2007 at 1:05am
It gets more complicated if you want to dynamically change text within one text field. You can format parts of a text object manually using the format toolbar buttons, but these don't let you do it dynamically. The only way I know of to do this is to use a formula that outputs an HTML string that uses the Font tag. Then tell the text object to display it as HTML.

The string would have to by something like this
My Name Is <font color='red'>Peggy</font>

You would have to incorporate these font codes into your formula so that you can change it as needed.

HTH.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.016 seconds.