我是Crystal Reports的新手(2天),我正在尝试遍历array
strings
并检查特定值。如果该值存在,请修改该值。
我在记录选择公式中做了这一切。但是代码的行为并不像预期的那样。请告诉我代码的问题: -
Local numberVar i;
For i := 1 to ubound({?Partner_Name}) Do
(
IF {?Partner_Name}[i] = 'Lincoln - MN' Then
{?Partner_Name}[i] = 'Lincoln'
Else If{?Partner_Name}[i] = 'LINCOLN - UT' Then
{?Partner_Name}[i] = 'LINCOLN'
Else
{?Partner_Name}[i] = {?Partner_Name}[i]
);
{Command.PARTNER_NAME} = {?Partner_Name}
感谢任何帮助..提前致谢
答案 0 :(得分:0)
这将'编译':
Local Numbervar i;
// assign multi-select parameter to string array
Local Stringvar Array partners := {?Partner_Name};
For i := 1 To Ubound(partners) Do (
Select partners[i]
Case "Lincoln - MN": partners[i]:="Lincoln"
Case "LINCOLN - UT": partners[i]:="LINCOLN"
);
// this line will raise an exception; you can't reassign the value
{?Partner_Name}:=partners;
// display the value
Join(partners, ", ");
...
答案 1 :(得分:0)
这里有一个解决方法..这不是经过测试的。而不是将值存储在参数字段中。尝试不同的方式。
Local numberVar i;
Local StringVar array a;
Local StringVar array b:=join({?Partner_Name},",");
// Not sure which function works here currently don't have CR tool
For i := 1 to ubound(b) Do
(
IF {?Partner_Name}[i] = 'Lincoln - MN' Then
a := 'Lincoln'
Else If{?Partner_Name}[i] = 'LINCOLN - UT' Then
a := 'LINCOLN'
Else
a := {?Partner_Name}[i]
);
3.现在在选择公式中使用如下:
{Command.PARTNER_NAME} IN a
让我知道它是怎么回事。