循环在水晶报告中公式字段的数据表中的记录中

时间:2014-02-13 09:44:14

标签: datatable crystal-reports crystal-reports-xi

datatable附加了Crystal Report,结构如下

TypeId
TypeName

我想根据条件

TypeName中显示GroupHeaderSection

例如

如果TypeId = 1则显示hans

如果TypeId = 2,则显示MNHS

我尝试使用以下公式来显示此datatable

中的记录
WhilePrintingRecords;
Local NumberVar result := -1;
Local NumberVar i := 1;
Local StringVar inString := "";
While i <= 5 And result = -1 Do
(
  // inString := IIF({DTPMS_RptLocationTr.LocationTypeId} = 1,{DTPMS_RptLocationTr.LocationTypeName},"")

   If {DTPMS_RptLocationTr.LocationTypeId} = 5 Then
     inString := {DTPMS_RptLocationTr.LocationTypeName};
   i := i + 1;
);
inString

有关如何解决此问题的任何建议

1 个答案:

答案 0 :(得分:0)

我找到了如何解决我的问题。

首先,我改变了从数据库返回的记录的方式,我返回了那样的数据

Type1 | Type2 | Type3
======================
hans  | MNHS  | nhues

所以现在我可以将数据直接从datatable绑定到报告标题