【问题标题】:How to write custom function in crystal report to be used for record selection如何在水晶报表中编写自定义函数用于记录选择
【发布时间】:2013-09-03 12:48:10
【问题描述】:

我在水晶报表中编写自定义函数以使用记录选择获取记录时感到困惑。

当我们在记录选择中创建公式时,它将根据使用的参数在生成的 SQL-Query 中添加 where 子句。现在我想编写自定义公式,它将以编程方式提取记录:

即使我已经写了一个函数:

Function (stringVar st)(
   stringVar selection; 
   if (st <> 'ALL') then (
        selection = st;
    )
    else(
        //In this case the user select only single value, it will fetch the result to that                //particular column value in the table.. otherwise it leaves that particular row..
        selection = "multiple selection";

    )
)

现在,使用 select Expert 在记录选择中使用自定义函数的代码是:

 if(myfunction({?parameter1}) <> "ALL") then
    (
        // what code should i write to select that particular record...
        if(myfunction({?parameter2})) <> "ALL" ) then
        (
            //do selection from the previously selection of rows which have this parameter
             if(myfunction({?parameter3}) <> "ALL") then
             (
                 //do selection from the previously selection of rows which have this 
                 //parameter
             )
             else (//do something else) 
        )
        else (//do something else)
    )
    else (//do something else)

谢谢,提前。

【问题讨论】:

  • 请用“水晶报告”和代表其版本的第二个标签标记您的问题。

标签: crystal-reports crystal-reports-2008


【解决方案1】:

您不需要为此使用自定义函数。假设你有两个字符串参数,ry:

// assumes you have a parameter value of 'All Countries' w/ a value of '0'
( '0' IN {?CountryCodes} OR {table.CountryCode} IN {?CountryCodes} )
// assumes you have a parameter value of 'All Regions' w/ a value of '0'
AND ( '0' IN {?RegionCodes} OR {table.RegionCode} IN {?RegionCodes} )

【讨论】:

  • 实际上,在我的水晶报告中,我有 8 个参数可供使用.. 使用上述条件会令人困惑.. 这就是我使用自定义函数的原因.. 另请参阅此问题: stackoverflow.com/questions/18487960/…
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多