首页 > 解决方案 > Crystal Reports 除以零,但有问题仅检查零以突出显示零

问题描述

嗨,我正在尝试完成一份水晶报告,摘要报告,但我得到了零错误除法。我已经查找了所有内容,但没有一个选项对我有帮助。已经存在的选项只会使我的数学公式将所有内容都归零。

if 1-({@dspStkWip}+{tblItem.OnOrderQuantity}/{@dspNeed})*100 > .15 
then crYellow
   else CrNocolor;

那么发生了什么,因为列中的需要为零,它最终会使所有内容都为 0。我只需要找到一种方法来实现零检查并查看它是否需要在列中突出显示。

标签: vb.netvisual-studiocrystal-reports

解决方案


{@dspNeed} 字段对我来说似乎是罪魁祸首。如果此字段包含 0 或 NULL 值,那么您将得到您描述的除以零错误。

尝试这个:

IF {@dspNeed} <> 0 THEN if 1-({@dspStkWip}+{tblItem.OnOrderQuantity}/{@dspNeed})*100 > .15 then crYellow else CrNocolor ELSE \\ code for how to handle values that throw division by zero error goes here


推荐阅读