Change the color of a text object using a formula in Crystal Reports

enter image description here I want to change the color of text in a text object using a formula in Crystal Report. I tried both

If {mnth_ttx.weight}>0 Then crRed; 

But the color does not change at runtime. I wrote this condition under the formula for editing a text object with a weight. But does not work. How to change text color using a formula

+4
source share
6 answers

Follow these steps:

  • Right click: select Format Field...
  • Select the Font tab, then click the conditional-formula button to the right of the color picker
  • Enter this formula: If {mnth_ttx.weight}>0 Then crRed Else crBlack
+4
source

Follow these steps:

  • Right-click: select Field Format.
  • select the font tab.
  • click on the X + 2 box to the right of the color picker. The formula editor opens.
  • Enter this formula:

     If {mnth_ttx.weight}>0 Then crRed Else crBlack 
+1
source

You can create a more advanced format using html. In the first text field you need to set the TextFormat property as crHTMLText. In this case, the text field will interpret html after assignment in the formula, you can put the following

 if {?PARAMETER}=3 then If not IsNull ({TABLE.FIELD1}) Then "<p><b><font color='#00559c'>" & {TABLE2.FIELD1} & "</font></b></p>" & {TABLE2.FIELD2} & ": " & {TABLE2.FIELD2} Else "<p><b><font color='#00559c'>" & {TABLE2.FIELD1} & "</font></b></p>" 
0
source
 if x> 0 then formula= color(159,255,159) else formula = crRed end if 

'' The values ​​in color (159,255,159) are colored (red, green, blue). These are the numbers that you will see when creating a custom color.

0
source

Right-click 1. Select the format of the object 2. Go to the border 3. Select Background Colorado 4. Click OK.

What is it. Everything is ready!

0
source

You can use the verified and validated "currentfieldvalue" rating.

  1. Right click on your item and click "Field Format"

  2. On the Font tab, click the Color button.

  3. Enter this:

     if currentfieldvalue > 0 then crRed else crBlack 
  4. That's all she wrote

0
source

Source: https://habr.com/ru/post/1394554/


All Articles