Obtain Sub-Report page numbers in reference to main report

L

Larry.Bargers

Hello,

I have a report containing 4 sub reports. I want to retrieve the page
number that each sub-report starts on in reference to the main report.
This would make it possible to display a Table of contents for the
main report. The sub report can vary in page length.

The report is layed out as follows:

Executive Summary (Main Report)

{Detail section}
Table of Contents

{Page Break}
Sub Report 1

{Page Break}
Sub Report 2

{Page Break}
Sub Report 3

Any assistance would be greatly appreciatedA

Larry
 
M

Marshall Barton

I have a report containing 4 sub reports. I want to retrieve the page
number that each sub-report starts on in reference to the main report.
This would make it possible to display a Table of contents for the
main report. The sub report can vary in page length.

The report is layed out as follows:

Executive Summary (Main Report)

{Detail section}
Table of Contents

{Page Break}
Sub Report 1

{Page Break}
Sub Report 2

{Page Break}
Sub Report 3


You can get the page number from the main report by
referring to:
Parent.Page
 
L

Larry.Bargers

How can I refer to the "parent.page". When I attempt this the
parent.page returns the current page I am view to the Table of Content
labels I wish to update.

Thanks
 
M

Marshall Barton

How can I refer to the "parent.page". When I attempt this the
parent.page returns the current page I am view to the Table of Content
labels I wish to update.


I don't understand. The subreport needs to retrieve its own
page number and store it somewhere that can be used later to
generate the TOC.

Ahhh, are you are trying to create the TOC before the
subreport's are processed? That's a pretty tricky thing to
try to do. Normally, a TOC is a separate report that
displays data that the primary report stores in a table.

If this is what you are thinking of doing, it just may(?) be
possible in very limited situations, but it's pretty
complicated and potentially slow. The key trick is to force
the report to be processed twice, once for the subreports to
be formatted so they can determine their page number and
again so the TOC can retrieve the page numbers and stuff
them into your TOC text boxes. This is accomplished by
having a main report text box that refers to the Pages
property. The usual text box with:
=Page & " of " & Pages
is sufficient.

Next, you need a module level Collection to store the page
numbers. I suggest that you use the main report's Report
Header section for your TOC. The code in the main report
would look something like this air code:

Public colPages As New Collection

Sub ReportHeader_Format( . . .
If Me.Pages <> 0 Then
Me.txtreport1 = colPages!report1
Me.txtreport2 = colPages!report2
Me.txtreport3 = colPages!report3
End If
End Sub

The code in each subreport report header section's Format
event would be like:

If Parent.Pages = 0 Then
Parent.colPages.Add Parent.Page, "report1"
End If

If you really require a separate TOC for each main report
detail record, then the situation will be way more complex
and I am not sure it can be done nor if I have time to try
figure it all out.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top