[AccessD] Page numbers in Subreport

Jim Dettman jimdettman at verizon.net
Tue May 14 14:58:25 CDT 2019


David,

  As is, the short answer is no.

  Page Header/Footers are not processed in a sub report.  That's why you're
getting the 0/0.  You'll have to take care of the page numbering yourself.

  A trick with subreports is to add a group with the expression =1 to add a
group header/footer.  Then set the group header's repeat section property to
true and place you headings in there.  Now you've got a spot where you can
increment the correct page count.  Store the page count in a text control on
the main report.  You can fetch it from there when you want to print the
page in the subreports.

  To get the number of pages, on the main report place a hidden text control
in the page footer with the controlsource of  =[Page] & " of " & [Pages].
This activates two pass mode.   On the first pass, the report engine will
run through all the pages to get the total.   You can tell your on the first
pass when .Pages = 0.   Note that on the first pass, OnPrint does not fire.

  On the second pass, .Pages will have the total page count, which you can
use in the subreport.

Jim.
----Original Message-----
From: AccessD [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of
David Emerson
Sent: Tuesday, May 14, 2019 2:57 PM
To: 'Access Developers discussion and problem solving'
Subject: [AccessD] Page numbers in Subreport

Hi Listers,

 

I have a report that has three subreports (and nothing else).

 

The subreports take up whole pages and near the bottom of each report is a
field with "=[Page] & " of " & [Pages]" as the control source.  If I run the
subreports on their own they show the correct page numbers for their report.
Depending on one of the fields in the subreport data, each record may fill 1
or 2 pages (always whole pages)

 

When I run the combined report the page numbering shows "0 of 0" (which I
have found is a "feature" of subreports).  I am wanting them to show the
numbers as if the page number fields were on the combined report (eg page x
of {total number of pages from the combined report}.

 

Because the position of the page numbering is not at the very bottom of the
sub reports it cannot go in a page footer of the combined report.

 

Does anyone know how I can get the page numbering of the subreports to
appear correctly?

 

Regards

David Emerson
Dalyn Software Ltd
Wellington, New Zealand

 

 

-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list