Displaying information from Datasets in the header / Report Builder 3.0 SSRS 2008 R2
I’ve searched on the web and haven’t found a solution yet that would work with the report I’m creating. Here is the structure of my report: HEADER ReportItems!FieldToShow.Value Code.myVar.Value Group 1 FieldToShow (First("Field 1", Group 2)) Code.myVar.setValue(First("Field 1", Group 2)) Group 2 Field 1 Field 2 Field 3 Field 4 Field 5 Field 6 SUBREPORT 1 SUBREPORT 2 (here is a PAGEBREAK) SUBREPORT 3 (here is a PAGEBREAK and RESETPAGENUMBER) FOOTER There are Pagebreaks after the first group and after the second group. Each group is about 3-10 pages big (every “group 1” starts from page 1). I need to display a Field from the Dataset in the header on every page except the first one, since that one has a different header. So far I’ve tried 3 different approaches. I always included the source where I first found them: Creating a textbox (FieldToShow) that has the required information in it and displaying its value in the header (with: ReportItems!FieldToShow.Value) didn’t work. When I put the field inside the Tablix, I would get the information only on the first and last page, since the subreports are longer than 1 page. http://geekswithblogs.net/Bunch/archive/2008/03/05/data-into-a-ssrs-header-again.aspx On the second approach I created an internal parameter that would have the information needed which I then used in the FieldToShow textbox, with the same results as on the first try. http://blog.irm.se/blogs/eric/archive/2006/05/25/Reporting-Services_3A00_-Data-in-a-Page-Header.aspx So I created a function, as is suggested in the third solution I found. The Value of “MyVar” is set everytime the second group iterates (Code.myVar.setValue(First("Field 1", Group 2))). And on every second Page of the several group I display this Value in the Header. This actually works quite well for all but the last page of each group. There it displays the data of the next person already. E.g. Page 1-9 have the headers of person 1, page 10 has the header of person 2. Page 1-7 of the 2<sup>nd</sup> set have the headers of person 2, page 8 has the header of person 3. http://www.andrewdenhertog.com/reporting-services/reporting-services-ssrs-get-data-value-into-page-headerfooter I slightly changed the Code from that website as follows: Public Shared Dim MyVar as String Public Function SetMyVar (var as String) as String MyVar = var End Function Is there any way to get it to display it properly on the last page too or any other workaround that I could use to make this work properly?
January 12th, 2011 7:10pm

Hi, Can you give us sample data so as to reproduce the issue? Currently, it is hard to understand the issue completely. thanks, Jerry
Free Windows Admin Tool Kit Click here and download it now
January 17th, 2011 9:02am

Hi, Here some sample data Client Name (Field 1 in the example) Bill No (Field 2 in the example) Bill total amount Bill details 1 (Subreport 1) Bill details 2 (Subreport 2) Bill summary (Sub Report 3) Mike Miller 123.456 1099.95 is an ID to a Subreport is an ID to a Subreport is an ID to a Subreport Josh Fisher 187.457 598.95 is an ID to a Subreport is an ID to a Subreport is an ID to a Subreport … … … … … … After every client, there has to be a pagebreak. And in the header I'd like to show the client name and the bill no on every page. Thanks! Regards!
January 24th, 2011 11:24am

Hi, The third approach (code) works when implemented as follows. Add the following Custom Code to the Report Public Shared Data1 As Object = "" Public Function SetData(NewValue As Object, Field As String) If Field = ClientName Then If NewValue > "" Then Data1 = NewValue End If End If End Function Public Function GetData(Field As String) If Field = ClientName Then Return CStr(Data1) End If End Function On the Report Body, create a dummy TextBox and set the Text Value of the Text Box as follows Code.SetData(First("Field 1", Group 2)),"ClientName") On the Report Header, create a TextBox to display the field to be shown on the header (eg: ClientName) and set the Text Value Property of the Text Box as follows =Code.GetData("ClientName") This approach will work fine even if the dummy TextBox created on the Report Body is not repeating on every page. But you have to ensure that the TextBox is placed inside the Group 2. Thanks, Prasanna. Service Delivery & Support Management
Free Windows Admin Tool Kit Click here and download it now
August 13th, 2011 10:43am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics