1

我对 Crystal Reports 很陌生(2 天前),我正在尝试循环arraystrings检查特定值。如果该值存在,请修改该值。

我在记录选择公式中做这一切。但是代码没有按预期运行。请让我知道代码的问题:-

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}

任何帮助表示赞赏..在此先感谢

4

2 回答 2

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, ", ");

...
于 2014-03-26T15:45:42.167 回答
0

这里有一种解决方法.. 这不是经过测试的。而不是将值存储在参数字段中。尝试不同的方式。

  1. 创建一个选择多个输入的参数。
  2. 然后创建一个数组并编写代码:
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

让我知道事情的后续。

于 2014-03-26T15:45:51.573 回答