Results 1 to 6 of 6
  1. #1
    2 Star Lounger
    Join Date
    Sep 2002
    Location
    Chicago, Illinois, USA
    Posts
    116
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Print at bottom of page on subreport (97 SR-2)

    I want to print text (label control) at the bottom of each page of a subreport. Subreport page footers won't work because they're not printed and I don't want the information printed at the bottom of every page of the main report, just on the several pages that the subreport prints on. Does anyone have an idea how to do?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Print at bottom of page on subreport (97 SR-2)

    I don't think this can be done without code (though I'd love to hear of a method without code).

    A. Are you willing to use VBA code?
    B. If the answer to A is yes, are you familiar with event procedures?

  3. #3
    2 Star Lounger
    Join Date
    Sep 2002
    Location
    Chicago, Illinois, USA
    Posts
    116
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print at bottom of page on subreport (97 SR-2)

    A. Yes, I'm more than willing to use VBA code and am very familiar with event procedures. One possibility I considered was using the technique I found in Microsoft Knowledge Base article 208979: How to print a group footer at a specific location. My problem with this is that I need to print at bottom of every subreport page, regardless of where group breaks may occur. I have coded using the MoveLayout, PrintSection, and NextRecord properties in other situations but I can't see how to use in this situation as these properties are specific to a particular report section.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Print at bottom of page on subreport (97 SR-2)

    The following works for me, but I haven't stress-tested it.

    Somewhere on the main report, for instance in the page footer, place two check boxes HeaderFlag and FooterFlag; they should be invisible in the final version, but I recommend leaving them visible during testing. It is also possible to use two module-level boolean variables instead.

    Here is code for the On Print event of the page footer section of the main report. It shows or hides some controls based on the value of HeaderFlag. The Nz function is used to prevent an error when opening the report.

    Private Sub PageFooter_Print(Cancel As Integer, PrintCount As Integer)
    lblProduct.Visible = Nz(HeaderFlag)
    lblProdName.Visible = Nz(HeaderFlag)
    End Sub

    The variables are reset on a new page of the main report if the previous page contained the report footer of the subreport:

    Private Sub Report_Page()
    If Nz(FooterFlag) = True Then
    HeaderFlag = False
    FooterFlag = False
    End If
    End Sub

    The following code is for the subreport. HeaderFlag is set to True (and FooterFlag to False) in the On Print event of the subreport header section, and FooterFlag is set to True in the On Format event of the subreport footer section.

    Private Sub ReportFooter_Format(Cancel As Integer, FormatCount As Integer)
    Parent!FooterFlag = True
    End Sub

    Private Sub ReportHeader_Print(Cancel As Integer, PrintCount As Integer)
    Parent!HeaderFlag = True
    Parent!FooterFlag = False
    End Sub

  5. #5
    2 Star Lounger
    Join Date
    Sep 2002
    Location
    Chicago, Illinois, USA
    Posts
    116
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print at bottom of page on subreport (97 SR-2)

    Hans,
    Thank you very much for the idea of placing the label control on the main report.
    After a considerable amount of tinkering I found that I could simply turn the label on in the subreport's ReportHeader_Print event and turn it off in the subreport's ReportFooter_Format event as follows:

    Private Sub ReportHeader_Print(Cancel As Integer, PrintCount As Integer)
    Parent!lblSeeSectionEF.Visible = True
    End Sub

    Private Sub ReportFooter_Format(Cancel As Integer, FormatCount As Integer)
    Parent!lblSeeSectionEF.Visible = False
    End Sub

    I did not need any code in the main report because I could directly set the Visible property of the label control from the subreport's events. Indeed, if I used the main report's Page event to turn a flag (check box control or module level variable) off, then only my first page of the subreport would print the label; the remaining pages of the subreport would not print the label.

    Other notes:
    - I had to use the subreport's ReportHeader_Print event rather than its ReportHeader_Format event because the OnFormat event printed the label on pages in the main report that preceded the beginning of the subreport where I wanted the label to print. Also I had to set the subreport's Report Header section to a non-zero height and its visible property to Yes in order for the OnPrint event to fire. I used a height of .01"
    - I used the subreport's ReportFooter_Format event rather than its ReportFooter_Print event because I found I had to set the Report Footer's ForceNewPage property to Before Section in order to have my label appear on the final page of the subreport. I set the height of the ReportFooter section to 0 which prevented any extra page from actually printing, but because of the zero height I had to use the OnFormat event because OnPrint doesn't fire under these conditions.

    Thanks again, Hans, for your help on this. I find this forum very helpful and read the "Daily archive of Access" posts everyday.

    Jon

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Print at bottom of page on subreport (97 SR-2)

    Hi Jon,

    I'm glad that my suggestions at least got you on your way. Apparently, this kind of problem always needs tinkering. My solutiion didn't work for you "out of the box", and vice versa: if I apply your method to the example I constructed yesterday, the page footer is not in synch with the subreport. But it depends very much on the exact situation and I have no reason to doubt your approach.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •