简体   繁体   English

Crystal Reports使用IF语句更改字段颜色

[英]Crystal Reports changing field color using IF statement

I am trying to change the background color of a row in crystal reports based on comparing two data fields. 我试图根据比较两个数据字段来更改水晶报表中一行的背景颜色。 For example. 例如。 If GPA_01 < GPA 02 then the background color should be red. else the background color should be white If GPA_01 < GPA 02 then the background color should be red. else the background color should be white . If GPA_01 < GPA 02 then the background color should be red. else the background color should be white When attempt to create the formula i get an error message saying the " a number is expected here" it's highlighting the field after the comparison sign in this case the <. 尝试创建公式时,我收到一条error message saying the " a number is expected here" ,在此情况下,在比较符号后加亮该字段。 I'm thinking the field after the < needs to be converted to a number but I'm not sure how to do that. 我在想<之后的字段需要转换为数字,但是我不确定该怎么做。

Any advice would be greatly appreciated. 任何建议将不胜感激。

Assuming that the two fields are numeric, try: 假定两个字段是数字,请尝试:

If {table.GPA_01} < {table.GPA 02} Then
  crRed
Else
  crNoColor

use CINT() to convert to integer 使用CINT()转换为整数

If CINT({table.GPA_01}) < cINT({table.GPA 02}) Then
  crRed
Else
  crNoColor
If CINT({table.GPA_01}) < cINT({table.GPA 02}) Then
'crRed'
 Else
 'crNoColor'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM