• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1115
  • Last Modified:

Subreports - Page Headers and Footers

Hi There,

I am trying to resolve an issue that I currently have on a report.  

I am trying to print an invoice.   The first page being a cover page with
        a) Page Header:    (Shown on the first page only, this is okay)
        b) Detail : Summary of Report
        c) Page Footer:  (with Subtotal, Taxes etc )   (Shown on the first page only, this is okay)
        d) Report Footer: Subreport to the invoice detail (THIS IS THE PROBLEM!!!)

THE PROBLEM OUTLINED
====================
Then I have a subreport linked to this cover page (in the Report Footer Section) showing the invoice detail.  

I currently have the detail coming up, but can't seem to show the Sub Report page headers or Sub Report Footers, only the detail.   Can anyone help me display the headers and footers of the subreport?

Cheers
GusK
0
GusK
Asked:
GusK
  • 6
  • 4
1 Solution
 
harfangCommented:
Hello GusK

The subreports report header and report footer print normally. If they don't, you must have done something  to prevent them from being printed.

The subreports page header and page footer is never printed. Nor is the page setup information used in any way, except for columns definitions. There is no way to activate the page headers of the subreport.

However, you can fake it. Create a top-level group on the expression =True for example (one group for the entire report), activate the group header, and set the property Repeat Section: Yes.

The new home-made page header will print even when used on a subreport.

Cheers!
(°v°)
0
 
GusKAuthor Commented:
Thanks for this.... I have managed to get the headers and footers

HOWEVER......

Can't get the page numbering to work as that only seems to show up in the page header and footer.

Also can't get the count of the number of pages to appear on the cover sheet (but can't think of how I could possibly link this to the subreports number of pages.

Any ideas on the page numbering as this is crucial on the invoice.

cheers
GusK
0
 
harfangCommented:
GusK

I'm afraid you will have to forget about page numbers. It might be possible using tons of subtle VB code, but I'm not up to it right now, and I don't see the point. The subreport does not count pages, obviously, but it can display the parent's page number. However, it will be the number of the page where the subreport started, not the actual page number. No luck there.

If you need page numbers on your main report, use the main report's page header or page footer. You mentioned that they appear only on the first page, and you also seem to use the page footer in a strange way.

Would you care to explain why you need to simulate the main report's page header or footer in the subreport?

(°v°)
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
GusKAuthor Commented:
Just to clarify a few things....

The front page - page footer has the subtotals (which are derrived via query) due to the fact that I need them appearing at the bottom of the page rather than straight after the detail.  (this detail is a variable length for each invoice as you can imagine).... using it in the page footer guarantees placement on the page.   (Is there an alternative?)

On the last point, I don't need the main reports page header and footer in the subreport, just need page numbers in the subreport, or a full count of pages for the entire report.  

IE Main Page reads:    Pages 1 of 30   (where 1 is the main report and 29 pages are in the subreport)
    Subreport Reads:    Counter in the footer from 2 of 30  --->  30 of 30

Hope that illustrates better.  
Cheers
GusK
0
 
harfangCommented:
It does.

You need the page footer on page one for layout purpuses (and it's true there is no easy solution to force any other section to the bottom of the pabe), and you later need the footer to display page numbers. hmm...

There is no trick to simulate a second page footer (which is a total shame in respect to alternating page footers, for example).

I'll have to come up with something... How do you turn the page footer off for all but the first page, by the way?

(°v°)
0
 
harfangCommented:
Hello GusK

I made some tests, and I didn't find a good solution. Some possible hacks:

 • Print the subreport as a main report, adding one to the page numbers (2-30). Record the last page number in a global variable, and then print the first page. The global variable is used instead of [Pages].

 • Manipulate the page footer so that all controls but the page number become invisible starting with page two. This is rather easy, I think.

 • Use Me.Print to print the page number on any predefined position on the page. This might however conflict with the subreport, because you cannot print outside of the margins.

 • Of course the page header is still available. But that is not an option, riight?

Tell me what you think.

(°v°)
0
 
GusKAuthor Commented:
Not fantastic at coding but they sound promising.

The page header can contain the page numbers..... not phased about that one....

If the page numbers can appear anywhere I will be happy.

Thanks again
GusK
0
 
harfangCommented:
Hello GusK

I created a collapsing page footer for you. This goes into the page footer's format event. In the sample, therer are two controls visible on pages two onwards: a textbox showing the page numbering and a ruler, which is set to invisible, so as not to show on the first  page.

I hope you can adjust this to your needs, I included some comments to make not to hard for a "non-fanatic" ;)

--------------------------------------------------------------------------------------------------------->8-----

Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As Integer)
'
' The page footer has two "views": 1) first page and 2) all other pages
'
' During the first formatting, the .Top, .Height, and .Visible properties of all
' controls are saved into their .Tag.
'
' For all pages after the first page, the page footer is collapsed, showing only
' two controls: a ruler called linRuler and the page number textbox, txtPageNumber
'
' When reformatting the first page (this will happen because the entire report is
' formatted twice), the section is  restored to it's original state.
'
'
    Dim sec As Section
    Dim ctl As Control
    Dim old() As String
   
    ' save some typing:
    Set sec = Me.PageFooterSection
   
    ' recording phase: .top and .height of all controls
    If sec.Tag = "" Then
        sec.Tag = sec.Height
        For Each ctl In sec.Controls
            ctl.Tag = ctl.Top & "/" & ctl.Height & "/" & Int(ctl.Visible)
        Next ctl
    End If
   
    If Me.Page = 1 Then
        ' section still untouched?
        If sec.Height = Val(sec.Tag) Then Exit Sub   ' ----- >
       
        ' we need to restore it
        sec.Height = Val(sec.Tag)
        For Each ctl In sec.Controls
            old = Split(ctl.Tag, "/")
            ctl.Top = Val(old(0))
            ctl.Height = Val(old(1))
            ctl.Visible = Val(old(2))
        Next ctl

    Else
        ' section already collapsed?
        If sec.Height <> Val(sec.Tag) Then Exit Sub   ' ----- >
       
        ' hide everything (well, almost)
        For Each ctl In sec.Controls
       
            ' adjust controls for "collapsed view":
           
            If ctl.ControlName = "txtPageNumber" Then
                ctl.Top = 120
                ctl.Visible = True
               
            ElseIf ctl.Name = "linRuler" Then
                ctl.Visible = True
           
            ' hide and collapse the rest:
           
            Else
                ctl.Top = 0
                ctl.Height = 0
                ctl.Visible = False
               
            End If
        Next ctl
        sec.Height = 0   ' minimal size
   
    End If

End Sub

--------------------------------------------------------------------------------------------------------->8-----

Good luck!

(°v°)
0
 
GusKAuthor Commented:
Hey Mate,

Couldn't get it to work..... will give you the points anyway for the effort that you put into the solution..... thanks again for all of your patience and feedback

GusK
0
 
harfangCommented:
GusK,

Sorry this did not work out. If you feel like playing a bit more with the idea, here is my test report (containing the code above). Sometimes a working sample makes the difference.

https://filedb.experts-exchange.com/incoming/ee-stuff/261-Q_21873690.zip

Thanks for points and grade, and success with your project!
(°v°)
0

Featured Post

Free recovery tool for Microsoft Active Directory

Veeam Explorer for Microsoft Active Directory provides fast and reliable object-level recovery for Active Directory from a single-pass, agentless backup or storage snapshot — without the need to restore an entire virtual machine or use third-party tools.

  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now