How to execute a custom code function only once in a report of a report services?

I need to execute a custom code function when the report is first loaded, and I need it to be executed only once. Where can I say?

+4
source share
2 answers

I'm not sure how the best way to do this. I do not think you have any events to cling to them, but you could invent it. For example, for a header to call a function to set a header, and as a by-product, you call your own 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 the report header there is a text field that is set to:

 =Code.GetTitleAndDoSomethingElse 

Ugly, but has to do the trick.

+5
source

In the menu bar, select "Report", then "Report Properties." From the pop-up menu, select the Code tab. Write your code here.

0
source

All Articles