I need to execute a custom code function when the report first loads, and I need it to only run once. Where do I put it?
views:
71answers:
2
+1
A:
From the menu bar select Report then Report Properties. In the pop up select the Code tab. Write your code in there.
jstell
2010-01-19 19:01:17
I have my code in a function in the code tab - where do I call it from? I can't find the onLoad event or similar.
Nathan DeWitt
2010-01-19 20:32:54
+3
A:
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.
Chris Latta
2010-01-20 09:11:07
I'm doing basically the same thing but in a field on the chart. I'll accept your answer, and maybe someone will come along later with the proper way to run code once.
Nathan DeWitt
2010-01-20 16:05:53