我是Crystal Reports的新手(2天前),我试图通过strings
的array
循环并检查特定值。如果该值存在,修改该值
我在记录选择公式中执行所有这些操作。但是代码并没有像预期的那样运行。请让我知道代码的问题:-
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}
任何帮助都是感激的。提前感谢
这将'编译':
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, ", ");
...
这里有一个解决方法。这还没有经过测试。而不是将值存储在参数字段中。试试别的方法。
- 创建一个可选择多个输入的参数
- 然后创建数组并编写代码:
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
让我知道进展如何