none
Subreport change header of the parent with custom code RRS feed

  • Question

  • Hello,

     

    I have a report that contains a sub report.

    The main sub report has a lot of informations about the main project.

    Each project has some parts. For each part, I use a sub report (the part has some sub parts tables...)

    Now, my customers want to see the header of the part on every page (so if he loses the first page he can still know what the report is about : it is information for a production line).

    I have seen that I can not use the header of the sub report, but I have seen that I can use another method with an event.
    Unfortunately, I don't understand how it works, and the help on MSDN tells nothing about that.
    Can you please tell me where I can find information about that (or how to do it)?

     

    Thank you

    Marc

    ---------------------------------------------------------------------------------

    Here is the information that I have seen but I don't understand how to use it.

    You can manipulate the main report page footer from the subreport by using code in a subreport event procedure. For example, if you put a text box named txtSubTitle in the main report page footer section, then the subreport's report header section's Format event procedure can do something like:

    Parent.TxtSubtitle = "MySubreportInfo"
    How can I work in the event? How to declare them? Where?

    Thank you

    Marc
    • Edited by Marc_Allard Friday, October 22, 2010 6:49 AM The information I have put could make someone believe that I had the solution but it was not the case, I don't know how to use this information
    Thursday, October 21, 2010 9:00 AM

All replies

  • Hi Marc_Allard,

    From your statement “Now, my customers want to see the header of the part on every page (so if he loses the first page he can still know what the report is about : it is information for a production line)”, Actually there is no need for you to set the Parent.TxtSubtitle property. I think you could keep the subreport’s header visible while scrolling by setting the property of Header should remain visible while scrolling.  

    Just right-click the report item and then select Property->select the checkbox of Header should remain visible while scrolling. Then browser the report, I think you could see the subreport’s header while you scroll the scroll bar. It is the same to Main report.

    If I misunderstand you, please feel free to let me know.

    Regards,

    Challen Fu

    Monday, October 25, 2010 2:55 AM
    Moderator
  • Hello,

     

    Thank you for your help. Here is what I want to do
    1) Here is small explanation of what I have :  Subproject 1 and 2 are parts of project 1 (normally there will be something like 20-30 for each project) but it is only an example
    Subproject 3 and 4 are parts of the second project

    |-Project1
          |Subproject1
          |Subproject2

    |
    |- Project2
          |Subproject3
          |Subproject4

    2) Here is what I want to have (all the things I do are to be printed. I don't understand why but all my customers only trust paper.)

    Page header (company logo, date / time of the print, page count...)
    After that, for every project there is a specific header for the current project.(Project Name / Description)

    These two headers are headers in the main report (the project is the main report)
    Every time there is a new Subproject, I do a page jump.
    Every sub project must show on the header of the page what sub project it is (so the description and the number of times the sub project must be done).
    I was hoping to be able so put that information in the header of the sub project but it is not possible (the header/footer of a sub report are never used : they are simply ignored). The only way I saw was to use the possibility for the sub report to change a text on the main report.

    I use a sub report for the sub projects because there are more than 10 different tables to show for every sub report and it is too hard to create a lot of groups...

    For example Where is what my pages will look like (I consider that the description of project1 is Project1, Subproject1 is Subproject1...)

    Page 1 :

    _________________________
    Project1
    SubProject1

    ......... (all about the subproject)

    _________________________

    Page2 :

    _________________________
    Project1
    SubProject2

    ......... (all about the subproject)

    _________________________

    Page3 :

    _________________________
    Project2
    SubProject3

    ......... (all about the subproject)

    _________________________

    And so on (for page 4...)

     

     

    Thank you for your time

    Marc

    Monday, October 25, 2010 6:44 AM
  • Hi Marc_Allard,

    It’s true subreport’s header or footer will be ignored in the main report, this is by design. So if you want to display subreport’s header or footer, I would recommend you put header/footer on the subreport’s  body  rather than main report. You need to open different subreport based on Project1’s name, so you should create one parameter for the subreport that is to decide which subreport should be open. I think your subreport’s header or footer should also changes based on the subreport you open, you could also control subreport’s header or footer’s content utilizing the parameter.

     From your draft, I still notice that you want to display one Project on one page, you could add a pagebreak to the Project group.

    If you have any question, please feel free to ask.

    Thanks,

    Challen Fu

    Tuesday, October 26, 2010 1:54 AM
    Moderator
  • Hello,

     

    That is what I make at the moment : The header of the subproject is in the sub report (main part) and all was fine (untill the customer told me that I had to put the header of the subproject on every page of the subproject.) As the sub project contains a lot of differents tables I can see no way to use the functions such as repeat with a table and things like that. That is why I was looking for something to modify the text of the header on the main project. I have been told it was possible, but no one seems to know how to do it.

    Marc

     

    Tuesday, October 26, 2010 4:13 AM
  • Hi Marc_Allard,

    Based on your infromation, I think you could add a group header when you add a parent group. The parent group could display the records on the main report, group header could display the subreport's header.

    Tuesday, November 2, 2010 3:22 AM
    Moderator
  • Hello,

     

    I am not sure that I understand correctly...

    Do you mean that I should use some groups instead of a sub report (because when I put a group in a sub report it doesn't work : the header only appear once and not when a table in the sub reports takes 2 or 3 pages.

    Also, my sub report has 18 different  tables. Some of them have only 1-2 records, but most of them have between 10-200 records (the maximum I have seen is more than 400 but generally you have in the 60-70 for 4 of the tables.

    That is why I use a sub report : I have different lists (one for every table) and all is fine.

    If I decided to remove the sub report logical, I would have to create a really big table and the group logical would becore really hard to manage (table 1 has 50 records and table 2 has 50 too, so I need 250 records and a way to manage all these records.

    That is why I need to be able to change the header of the parent report in a sub report. (or there is something I am missing about the groups)

     

    Thank you again for your time

    Marc

    Tuesday, November 2, 2010 7:45 AM