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.
精彩评论