Friday, March 9, 2012

ReportItems in my footer

I am having a problem viewing my footer on all pages of my report. I have created a page footer that reads
="The " & ReportItems("textbox213").Value
I am getting the value on the first page only and then only getting "The" on the rest.
My "PrintOnFirstPage" and "PrintOnLastPage" are both marked True in the Page Footer properties. I am completely confused. This is not the only textbox in my footer I have two others both which print on all pages, but neither of them use the ReportItems.

Can anyone help on this?

Thanks....Cin

You could try storing the value in a global variable, and then retrieving from the variable...

in the code, something like:

global mystr as string

public function setvar()

mystr = ReportItems("textbox213").Value

end function

public function getvar() as string

return mystr

end function

In the top of the report after textbox213 is populated, dump a hidden textbox with this value.

=Code.setvar()

And then in the footer...

="The " & Code.getvar()

Have not tested this but a used something similar when I had to get a list of values and retrieve them in a different part of the report.

cheers,

Andrew

|||

I used your example to the "T" and I am receiving some errors. When I use the line
mystr = ReportItems("textbox213").Value

the report cannot build, throwing the errors as follows:

[rsCompilerErrorInCode] There is an error on line 2 of custom code: [BC42021] Function without an 'As' clause; return type of Object assumed.
[rsCompilerErrorInCode] There is an error on line 7 of custom code: [BC30469] Reference to a non-shared member requires an object reference.
Build complete -- 1 errors, 1 warnings


It doesn't look like ReportItems is the right method call, and I can't find any documentation for the available objects and/or methods from the code window. Can you supply your exact code for me to look at and/or a link to a good reference for objects to use? (Something with code examples would be super... as Wrox's Pro SQL Server 2005 Reporting Services only has simple code that doesn't reference the object model.)

If you can think of anything that would help that would be great!

Thanks-Cin

|||

Hi there,

Apologies... I pulled that code out of my head. Guess I am a bit rusty.

The errors above would indicate you need to specify "public shared function setvar() as object" and public shared function getvar() as string.

You may need to pass in the ReportItems to the setvar function... something like...

public shared function setvar(byval passedinreportitem as string) as object

mystr = passedinreportitem

end function

public shared function getvar() as string

return mystr

end function

In the top of the report after textbox213 is populated, dump a hidden textbox with this value.

=Code.setvar(ReportItems("textbox213").Value)

And then in the footer...

="The " & Code.getvar()

Here are some additional references to code behind that I could find...

http://www.odetocode.com/Articles/130.aspx

and here

http://www.deeptraining.com/litwin/Litwin_SQLReportingSrvcs.pdf

and here

http://blogs.msdn.com/swisowaty/attachment/661446.ashx - lots of goodies.

Lots of examples searching the forums for =Code too.

Hope this helps.

cheers,

Andrew

No comments:

Post a Comment