March 29, 2007 at 8:57 pm
I'm writing a formula under the Code tab to calculate a percentage difference between two fields (this carries on from my earlier post today). I've written the following formula:
'Public Shared Function PcDiff(ByVal MonthsAgo As Integer) As Single
'
'Dim ThisMonthField As String
'Dim LastMonthField As String
'
'ThisMonthField = MonthField(MonthsAgo)
'LastMonthField = MonthField(MonthsAgo + 12)
'
'PcDiff = Fields(ThisMonthField).Value/Fields(LastMonthField).Value
'End Function
As you can see, I want to get the percentage increase or decrease for the last (x) month versus (x) month 12 months prior. Whenever I try to reference Fields from inside the Code tab, I get this error:
"reference to a non-shared member requires an object reference"
I can work around this by passing two singles to the formula, and referencing the fields from inside the report's table rather than the code tab. However, this isn't as clean. How can I reference Fields! objects from inside the Code tab?
July 11, 2008 at 7:38 am
Hi,
you could create parameters for PcDiff Function and paas the values of fields in PcDiff.
However you can't access the Field values directly by using Fields!FieldName.Value
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply