How to prevent subREPORTS from breaking across pages? (1 Viewer)

mminieri

New member
Local time
Today, 18:26
Joined
Jul 8, 2018
Messages
2
I have a dynamic REPORT, the contents of which are determined by "sections" (subjects) of information needed
and selected by a user from a FORM. These "sections" are TABBED PAGES on the form and there are about 30 of them.
Every RECORD can thus have a siginificant quantity of different combinations of "sections". On PREVIEW / PRINT
each "section" is a subREPORT however, ONLY THOSE WITH DATA appear on the report. No subreport consumes an entire
page and - depending on their heights (variable) - more than one can fit a single page. The number of pages needed
is not important to me. The structure is such that there are no large blank spaces or blank pages on the REPORT.
All of this works very well (I'm running Access 2016).

There is only 1 PROBLEM ISSUE at this point: If the last subREPORT on a page will not fit entirely on that page, that
subREPORT gets broken so that PART of the subREPORT appears at the top of the next page. The OBJECTIVE of this Post is
to find a solution that will force the subREPORTS move - as a complete single section - to the next page instead of
breaking. The following typical solutions do not work;

* "KeepTogether" does not work on "SUBreports" no matter where it is applied.

* I cannot use GROUPING/SORTING because the limit is about 20 using headers and footers, and I have about 30.

* Simply inserting a conventional "pagebreak" on the report would simply add pages and bloat the report to the extreme.

I am actually quite a novice at developing with this complexity, so any solution will need to be conveyed with the
complete coding to try please. I don't need suggestions like having less "subreports". There are indications online that
my objective is "IMPOSSIBLE" and maybe it is. I suspect that a solution - if there is one - will be a long, complex code
the can somehow determine the HEIGHT of the subREPORTS and the space available for it, then force a page break if it wont fit.
 

Ranman256

Well-known member
Local time
Today, 11:26
Joined
Apr 9, 2015
Messages
4,339
You can't.
At some point the sub rpt must spill over the page.
It cannot fortell the future.
 

JHB

Have been here a while
Local time
Today, 17:26
Joined
Jun 17, 2012
Messages
7,732
Could you post your reports and some sample data that shows your problem, (zip it because you haven't 10 post yet)?
 

isladogs

MVP / VIP
Local time
Today, 16:26
Joined
Jan 14, 2017
Messages
18,209
You can't.
At some point the sub rpt must spill over the page.
It cannot fortell the future.

Reports 'foretell the future' all the time by printing 'Page 1 of 5' etc in the footer.
You can also optionally restart the numbering after each group has completed.
Access does that by making 2 passes before printing.

Having said that, I have a report with up to 10 small subreports that I tried to prevent breaking across pages. The only way I managed to do so was to use carefully placed page breaks

BUT a solution was suggested at another forum where this was cross posted.
Place each report in its own section.
For more info, see https://social.msdn.microsoft.com/Forums/office/en-US/07374a44-eddb-46b9-b412-dcb517990d31/start-a-subreport-on-a-new-page-if-it-doesnt-fit-on-current-page?forum=accessdev

The issue then becomes the number of sections available on a report but its unlikely to be an issue.
You can have up to 754 controls or sections over the lifetime of a report
 
Last edited:

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 23:26
Joined
May 7, 2009
Messages
19,233
here is a sample dynamic report (MainReport).
there are two subReports (AA) and (BB).

view the mainreport in print Preview.
see that BB subreport fits in the same
page.

close the report and add more records to table BB.
view the report again.

see the code behind sub report AA (first sub report).
 

Attachments

  • sampleDynamicReport.zip
    33.6 KB · Views: 274

Users who are viewing this thread

Top Bottom