Page Breaks

G

Guest

Ok....... I am have a great time trying to get a page break to happen the way
I want it to. :)

On the first page, data from a sub-report will print anywhere from mid-page
to end of page. There is another sub-report that prints after it. I cannot
allow the field headers and first two rows of data, of this sub-report, to be
separated.

I inserted a page break at the top of the section that has the 2nd
sub-report. I want to be able to make the page break visible if the details
of the 1st sub-report extends to far down the page to allow for the 2nd
sub-report to print the headers and two rows of data.

Is there a way to identify where on the page the last row of data from the
1st sub-report ends? If I can test for that, I can probably make the page
break visible when needed.

Thanks in advance!

Dwight
 
A

Allen Browne

The trick is to place each subreport in a different section of the main
report. Then (assuming the main report's KeepTogether property is set to
Yes), the 2nd subreport won't start printing on a page unless it will all
fit. No page break is needed.

To create the extra section:
1. Open the main report in design view.

2.Open the Sorting And Grouping dialog (View menu).

3. Choose the primary key field of the main report (so it changes each
record).

4. In the lower pane of the dialog, set the Report Header to Yes (so Access
creates a section for it).

5. Move the first subreport into this section.

6. Make sure the section's KeepTogether property is Yes.
 
G

Guest

Allen,
Thanks for the information, but I already have the 2 sub-reports in
different sections, with the KeepTogether properties set. The problem is
that the second sub-report cannot be set to keep together without the
possibility of creating a big empty space at the bottom of the first page.
However, if the headers and first two line of detail cannot be printed on the
first page, I need it to start printing on the scond page.

Is there a way to determine where the 2nd section will start on the page and
then make the page break visible if needed.

If section2.? > # then
DoCmd.RunMacro "YesPageBreak"
Else
DoCmd.RunMacro "NoPageBreak"
End if


Thanks!

Dwight
 
A

Allen Browne

You could place a Page Break control (in the toolbox) at the top of the
section that contains the 2nd subreport.

Then in the Format event of the section, examine the Top property of the
report. If it's too far down the page, force a page break by setting the
Visible property of the Page Break control.

Note that the Top property will be given in twips, where 1440 twips = 1
inch. Also, the Page Break does have a Visible property, even though the
Intellisense does not show it.
 
G

Guest

Allen,
Thanks!
That is what I am working towards, but I have not been able to get the
proper syntext to determine the Top of a section.

Dwight
 
A

Allen Browne

This example makes the page break visible only if the Top property is 9
inches or more:

Dim bShow As Boolean
If Me.Top > 9 * 1440 Then
bShow = True
End If
With Me.PageBreak1
If .Visible <> bShow Then
.Visible = bShow
End If
End With
 

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