开发者

How do I execute a custom code function only once on a reporting services report?

开发者 https://www.devze.com 2022-12-16 18:15 出处:网络
I nee开发者_开发技巧d to execute a custom code function when the report first loads, and I need it to only run once.Where do I put it?I\'m not sure how the best way to do this is. I don\'t think you g

I nee开发者_开发技巧d to execute a custom code function when the report first loads, and I need it to only run once. Where do I put it?


I'm not sure how the best way to do this is. I don't think you get any events to hook in to, but you could fudge it. For example, have the header call a function to set the title, and as a by-product call your custom code function once:

Public Dim ReportTitle As String = ""

Public Function GetTitleAndDoSomethingElse As String
    If (ReportTitle = "") Then
        ReportTitle = "My Report Title"
        ' Do your stuff that runs once here
    End If
    Return ReportTitle
End Function

Then in your report header have a text box that is set to:

=Code.GetTitleAndDoSomethingElse

Ugly, but should do the trick.


From the menu bar select Report then Report Properties. In the pop up select the Code tab. Write your code in there.

0

精彩评论

暂无评论...
验证码 换一张
取 消