Header Data Only Appears On first Page

  • In my Employee Data Report I would like the employee's name to appear at the top of each page.

    I put a text box (called EmpName) with a reference to the Name field (=Fields!Name.Value) in the body of the report and then put a reference to that field (=First(ReportItems!EmpName.Value)) in the Page Header layout.

    The name appears correctly at the top of the first page of the report, but only the static text, without the name, appears on all succeeding pages of the report.

    What am I doing wrong?

  • Make sure that "Repeat report item with data region on every page is selected " option is selected for that text box.

    and also select data region for that ....that can be ur table/matrix/chat...

    this might help u ....

  • Checking "Repeat report item..." alone has no effect.

    My entire report is in a List region. If I set the "Repeat" Data Region to that List region I get an "A RepeatWith must be a data region within the same containing object as the report item" error. It doesn't matter if the text box is inside or outside the List region.

    Note that the List region spans multiple pages.

  • I don't think you can successfully use a dataset field in the header or footer of a report. I think you can only use globals there.

    I'd use a table instead of list and put the EMployee name in the top group and repeat group header on each page forcing a new page for each Group.

  • Well, I gave up trying to use the report header.

    It seems to me that there is a basic flaw in the concept of a report header. The header can only display dynamic data that is on the current page. But since it refers to that one field, it can't refer to data on any other page. Hence only the header on one page can contain the data.

    I put all of the variable length tables at the end of the list region and then figured out where the page breaks would occur. I then just added the "header" info as standard text boxes at the start of each page. This will work fine unless the variable length data exceeds one page.

  • Here is a solution that works for putting detail file fields into the heading as well as handling header overflow problems when subreports do page breaks and the main report heading contains blank values.

    First, define a ReportItems! collection field in the body of the report with something like this:

    Make a textbox named "StaffRequestor" instead of textbox1 in the report body. Create a texbox in the heading referring to the ReportItems! field, like this: =ReportItems!StaffRequestor.ValueThis will populate the heading field with the StaffRequestor field value. But, what to do about the page overflows where the heading fields are blank?

    Define in the Report Properties Code section (where custom code is put) this code:

    Dim staffRequestor As String = Nothing

    Function GetSetStaffRequestor(ByVal staff As String) As String

    IF staffRequestor = Nothing Then

    staffRequestor = staff

    End If

    Return staffRequestor

    End Function

    This variable and function defines a global variable and a get/set function that only sets it only one time. Back in the heading textbox, change the value to =Code.GetSetStaffRequestor(ReportItems!StaffRequestor.Value)This will make the field value appear in the heading on overflow pages.

    Hopefully this will help people like me that search fruitlessly for work-arounds for design quirks.

  • Hi

    Just save the last valid value in a variable and then use that saved value when the reportitem isn't available. RMaughans reply was close, but still just returning a default instead of the needed out-of-scope value of the current data bound report item.

    Just changing a few lines in that code gives the solution to the problem at hand.

    Let's say I have a (hidden) textbox named FOOTER on the page that I need to reference and display in the footer on every page for each data post, no matter how many pages the post spans; in the footer I insert a textbox and set the expression to:

    [font="Courier New"]=Code.GetFooter(ReportItems!FOOTER.Value)[/font]

    At render time, this results in a call to the function GetFooter passing in the value of the hidden FOOTER field on the page. On page one this equals the actual value that I wish to display, but on the following pages this would equal Nothing.

    In the report properties code section, I place this:

    [font="Courier New"]Dim lastfooter As String = Nothing

    Function GetFooter(ByVal currentfooter As String) As String

    If Not currentfooter = Nothing Then

    lastFooter = currentfooter

    End If

    Return lastfooter

    End Function[/font]

    Thus, returning the last received value that didn't equal Nothing.

    And thats it. And it doesn't fail if you browse the report backwards, because every new data post is validated top-down, no matter how you step thru the pages. It also works fine for exporting to different formats, though I've had some confusing results with .doc. But who hasn't?

    This is also good for images. You just output the image to a hidden textbox on the page, then go about it the same way, except you use =Convert.ToBase64String(Fields!Photo.Value) in the textbox expression, and Convert.FromBase64String as you call your function to get the value to use in your header/footer image field.

    Hope this helps!

    Regards

    /Martin

  • Thanks mklefelt, for your comments and tip about images using this approach. I didn't stress in the original post that the main idea is to use a VB variable to hold the header value. Instead of the program loading the value from a file's data field (which it can't do) to write the heading value, it loads the value from a program variable (to which it always has access). My particular problem only needed a default value, so I thought of the solution is terms of that. Your solution is better because it works for all situations, not just for a default situation.

  • Hello,

    This solution works but i am having same value in footer instead different value each time for list control. Can you please advise how can i solve that?

Viewing 9 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply