Friday, March 9, 2012

Reference a textbox in a report SSRS 2000

I am working in SSRS 2000, and I have a report using a table. In the footer of the table I want to do a calcuation. I have a textbox in the table called "SumAmtCurrent", which is a sum value for a field in my dataset. I have another field in my dataset, "TotalRevCurrent", and I would like to take this second field, subtract the value in the textbox "SumAmtCurrent", and have the result in the footer of the table. I tried to reference the textbox using ReportItems!SumAmtCurrent.Value - but that gives me the following error

"...The value expression for the textbox ‘textbox7’ refers to the report item ‘SumAmtCurrent’. Report item expressions can only refer to other report items within the same grouping scope or a containing grouping scope..."

Is there a way I can get this total into my report?

Thanks in advance!

One way would be to use a Global variable and some custom code.

Something like this... (untested)

' Put this in the code tab

Protected MyValue as Object

function setValue(value as object) as object
MyValue = value

end function

function getValue() as object
return MyValue

end function

'Set this in a hidden textbox above where you want to get the value

=Code.setValue(value)

'Get this where you want to get the value

=MyField.Value / Code.getValue()

Hopefully this gives an idea of how to do something like this. Apologies if the code doesn't work out of the box but the concept should be ok.

cheers,

Andrew

No comments:

Post a Comment