Unwanted page break

B

BruceM

I have a report that is an index of documents, grouped by customer. The
actual documents are contained in physical binders. A new binder is started
when the previous one is full. The index needs to correspond to the
binder's contents. For instance:

Alpha Corp.
Doc1
Doc2

Bravo Corp.
Doc1
Doc2
...
Doc20

Charlie Corp.
Doc1
Doc2
...
Doc35

The page break needs to happen at Charlie Corp. To accomplish this I have
created a PageBreak table that contains the CompanyID for the companies at
which the page break occurs. I have joined this table to the report's
Recordset query. The text box txtPageBreak is bound to the Company field in
the PageBreak table. I added a manual page break brkCo to the group header.
In the group header's Format event:

Dim blnBreak As Boolean

blnBreak = Not IsNull(Me.txtPageBreak)
Me.brkCo.Visible = blnBreak

This works, except that I have set the group header's Header Repeat property
to Yes since some company's documents occupy several pages. In the example
I have given I selected Charlie Corp as the company at which a page break is
to occur. The Charlie Company listing occupies two pages, so the page break
is visible on each page, resulting in a blank page between the two Charlie
Corp. headings. If I could identify that a repeated section header is the
second instance of that header I could make it so the page break is visible
only at the first instance of the header, or something like that.

In practice there are a number of companies at each letter of the alphabet,
some with one or two documents and others with many documents. Also, the
breaks don't necessarily occur between letters of the alphabet. If the
question to me is why I didn't use grouping, my reply is that I couldn't
figure out a way other than to create a Number grouping field, and assign
the value of 10 to all of the A and B companies, and a value of 20 to all of
the companies in the next group, etc., then group on that field. Or maybe I
could have used a ranking query in some way.
 
B

BruceM

After some searching I discovered something Marshall Barton posted some
years ago that I adapted to my situation. I added an unbound text box
txtCount to the Detail section, with its Control Source =1 and its Running
Sum Property set to Over Group. In the code I added a test for the value of
txtCount:

Dim blnBreak As Boolean

blnBreak = Not IsNull(Me.txtPageBreak) _
And Me.txtCount = 1
Me.brkCo.Visible = blnBreak

I already have it set so individual records don't break across the page.
Even if that happened I expect I could use the section's HasContinued
property. I had run into a dead end there, by the way, as it applies only
to records, not sections, that break across the page, but I spent a while
learning that.
 
M

Marshall Barton

BruceM said:
After some searching I discovered something Marshall Barton posted some
years ago that I adapted to my situation. I added an unbound text box
txtCount to the Detail section, with its Control Source =1 and its Running
Sum Property set to Over Group. In the code I added a test for the value of
txtCount:

Dim blnBreak As Boolean

blnBreak = Not IsNull(Me.txtPageBreak) _
And Me.txtCount = 1
Me.brkCo.Visible = blnBreak


In your case, I think you can avoid all the complications
with RepeatSection by moving the page break to the company
group footer (and adjusting the breaks table to indicate
that a break comes after the company).
 
B

BruceM

Thanks for the idea. I should have mentioned I tried that. I tested it by
moving the page break to the company group footer and removing all code from
the group header. This would force a new page after every company, which is
OK for a test. The trouble was that each company's group header information
(including the company name) appeared at the top of its own page, and again
at the top of the next page, even if there were no entries for the company
on that second page. The only way I could find to make that problem go away
was to change the Repeat Section property of the group header to No, but
that was no good if a company's listing spanned several pages.
Maybe there is a combination of settings that I missed, but I suspect the
Repeat Section problem is intractable.
 
M

Marshall Barton

Let's forget the group footer idea.

Here's an off the wall thought. Create two levels of
grouping on the same company field. Put the page break by
itself in the outer group header with no white space. Use
repeat section on the inner header.
 
B

BruceM

Hmm. Interesting thought. I'll give that a try. It may not be today, but
I should get a chance before the end of tomorrow. I'll post back with the
results.

Marshall Barton said:
Let's forget the group footer idea.

Here's an off the wall thought. Create two levels of
grouping on the same company field. Put the page break by
itself in the outer group header with no white space. Use
repeat section on the inner header.
--
Marsh
MVP [MS Access]

Thanks for the idea. I should have mentioned I tried that. I tested it
by
moving the page break to the company group footer and removing all code
from
the group header. This would force a new page after every company, which
is
OK for a test. The trouble was that each company's group header
information
(including the company name) appeared at the top of its own page, and
again
at the top of the next page, even if there were no entries for the company
on that second page. The only way I could find to make that problem go
away
was to change the Repeat Section property of the group header to No, but
that was no good if a company's listing spanned several pages.
Maybe there is a combination of settings that I missed, but I suspect the
Repeat Section problem is intractable.

"Marshall Barton" wrote
 

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