【问题标题】:Nested Crystal if statement not working嵌套 Crystal if 语句不起作用
【发布时间】:2017-01-19 08:16:59
【问题描述】:

早安,

我在 Crystal 子报告中有以下公式,但它没有返回任何值。我知道存在十多个记录的数据,我使用了检查功能并且没有给出语法错误,并且我遵循了以下问题“Crystal Report: How to evaluate multiple IF statements in one formula?”中给出的示例。

公式如下;

(if {?Pm-Enquiry.EnquiryId} <1000 and
{DocumentType.DocumentSubtype} = "DocumentSubtype1" then
left ({DocumentSubtype1Table.Field1},3) else
left ({DocumentSubtype1Table.Field1},4)
);
(if {?Pm-Enquiry.EnquiryId} <1000 and
{DocumentType.DocumentSubtype} = "DocumentSubtype2" then
left ({DocumentSubtype2Table.Field1},3) else
left ({DocumentSubtype2Table.Field1},4)
);
(if {?Pm-Enquiry.EnquiryId} <1000 and
{DocumentType.DocumentSubtype} = "DocumentSubtype1" then
left ({DocumentSubtype3Table.Field1},3) else
left ({DocumentSubtype3Table.Field1},4)
);

公式应确定 ID 是小于还是大于三位,并从 DocumentSubtypeTable 中检索前 3/4 位。不幸的是,ID 已与该字段中的日期合并,因此必须使用此公式。

如果你们能提供任何帮助,我们将不胜感激。

【问题讨论】:

  • 那是您创建的公式吗?你想做什么?
  • 这是我修改后的公式。基本上,每个文档子类型中都有一个字段,例如“1992 12/01/2016”或“123 01/01/2017”。我只希望公式根据查询 ID 的长度返回该字段的前 4 或 3 位数字。
  • 显示一个给定的例子和一个给定的结果。

标签: if-statement crystal-reports formula


【解决方案1】:

也许是因为您没有返回值。 尝试以下操作(定义一个变量,将结果填入其中,然后返回它。):

StringVar StrValue;

(if {?Pm-Enquiry.EnquiryId} <1000 and {DocumentType.DocumentSubtype} = "DocumentSubtype1" then
StrValue := left ({DocumentSubtype1Table.Field1},3) else
StrValue := left ({DocumentSubtype1Table.Field1},4)
);

(if {?Pm-Enquiry.EnquiryId} <1000 and {DocumentType.DocumentSubtype} = "DocumentSubtype2" then
StrValue := left ({DocumentSubtype2Table.Field1},3) else
StrValue := left ({DocumentSubtype2Table.Field1},4)
);

(if {?Pm-Enquiry.EnquiryId} <1000 and {DocumentType.DocumentSubtype} = "DocumentSubtype1" then
StrValue := left ({DocumentSubtype3Table.Field1},3) else
StrValue := left ({DocumentSubtype3Table.Field1},4)
);

StrValue;

【讨论】:

  • 感谢您的快速回复。我没有大量使用 Crystal 变量的示例值是什么?
  • 抱歉,您能澄清一下您的问题吗?没看懂
  • 在本例中,StrValue 是我们定义、填充、然后返回的变量。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-01-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-20
  • 1970-01-01
相关资源
最近更新 更多