function - 来自报告函数的 SSRS 引用报告变量

标签 function reporting-services reference

在 SSRS 中,是否可以从报告函数中引用报告变量?

下面是我的报告功能。与其在函数中声明和设置 MaxRFWIDRange,不如引用同名的报告变量。

Function ValidateRFWIDRange(FromRFW As Integer, ToRFW As Integer) As Boolean

    Dim DiffRFW As Integer
    Dim MaxRFWIDRange As Integer
    MaxRFWIDRange = 10000
    DiffRFW = ToRFW - FromRFW

    If DiffRFW > MaxRFWIDRange Then
        Return False
    Else
        Return True
    End if
End Function

最佳答案

看起来你可以做到这一点。

我通过添加一个变量 TestVariable 对此进行了测试。到报告,然后添加以下自定义代码:

Function TestVariableFunctionality(var as Microsoft.ReportingServices.ReportProcessing.OnDemandReportObjectModel.Variable) As String
    Return var.Value
End Function

我从文本框中调用该函数,如下所示:
=Code.TestVariableFunctionality(Variables!TestVariable)
这会将文本框中的变量值作为字符串输出。

您必须将完整的命名空间声明为 Microsoft.ReportingServices.ReportProcessing.OnDemandReportObjectModel.Variable , 因为 Variable单独没有定义。请参阅下文了解更多信息。

Accessing variable in SSRS function

From an MSDN blog:

Assume that you've created a report variable named "Reportvariable1".

All you need is a piece of custom code.

Public Function SetVariableValue(val as Microsoft.ReportingServices.ReportProcessing.OnDemandReportObjectModel.Variable)

val.Value = val.Value + 2

End Function

As simple as that. All i'm doing in the function is, take the report variable reference, add 2 to the existing value. That's it.

How you can call this function from your report item?

=Code.SetVariableValue(Variables!Reportvariable1)

This will do the magic. Also note that in the above expression i'm just passing the variable reference and not its value.

关于function - 来自报告函数的 SSRS 引用报告变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40644956/

相关文章:

reporting-services - 有没有办法在运行时更改 sql 报告图表类型和子类型?

c++ - 如何修复 "reference cannot be bound to dereferenced null pointer"警告

java - 我需要一些有关 Java 撤消功能的帮助

c - 在函数中通过指针修改 char* 会导致崩溃

c++ - 从没有参数的函数返回整数数组

php - Laravel 5 - SimplePaginate 函数在这里不起作用?

asp.net - 什么是 SQL Server 报告服务?

html - SSRS : How to display a hyperlink in sql services reporting

rust - Rust中有多位引用读者和一位引用作家

excel - 在 Excel 2007 中进行双单元格引用