Turning page header on and off

  • Thread starter Thread starter Bob Howard
  • Start date Start date
B

Bob Howard

I have a report with several group headers (and one has a footer), plus a
page header section. These are a series of receipts for money received.

On the first page of each receipt, I don't want to print the page header
section. The first (most major) group header section contains all the
information to be printed at the top of the first page of any receipt.

But if any receipt continues to a second page, I do want to print the page
header section ... it's considered an "overflow" page and the header simply
contains the receipient's name and the column headings.

Using VBA code behind all this, I've been using the "page number control"
(in the header) as a flag to indicate whether the page header section should
print. Initially, this is set to zero. In the format event for the page
header section, I add one to the page number. If the result is one, then I
return with "Cancel=True" and the page header does not print. If the result
is other than one, I allow the page header section to print. I do all this
only when "FormatCount=1".

When the last line of an individual receipt prints, I set the page number to
zero again (in preparation for the next receipt). I know when the last line
prints because I have a special group footer with a print event. This group
footer will always be the last thing to print for the receipt, and merely
contains a small blank space (no controls).

Now here's the problem. Every so often, I'll be missing the "overflow" page
header. This should only occur when the page number is reset to zero. That
would indicate that the print event for that little blank area has fired.

Is it possible that I'm retreating from the print event and the entire
"overflow" page is being re-formatted? That's the only thing I can think
of.

Should I implement a "retreat" event for that little blank area where I set
the page number page to where it was before I made it a zero?

bob
 
Bob said:
I have a report with several group headers (and one has a footer), plus a
page header section. These are a series of receipts for money received.

On the first page of each receipt, I don't want to print the page header
section. The first (most major) group header section contains all the
information to be printed at the top of the first page of any receipt.

But if any receipt continues to a second page, I do want to print the page
header section ... it's considered an "overflow" page and the header simply
contains the receipient's name and the column headings.

Using VBA code behind all this, I've been using the "page number control"
(in the header) as a flag to indicate whether the page header section should
print. Initially, this is set to zero. In the format event for the page
header section, I add one to the page number. If the result is one, then I
return with "Cancel=True" and the page header does not print. If the result
is other than one, I allow the page header section to print. I do all this
only when "FormatCount=1".

When the last line of an individual receipt prints, I set the page number to
zero again (in preparation for the next receipt). I know when the last line
prints because I have a special group footer with a print event. This group
footer will always be the last thing to print for the receipt, and merely
contains a small blank space (no controls).

Now here's the problem. Every so often, I'll be missing the "overflow" page
header. This should only occur when the page number is reset to zero. That
would indicate that the print event for that little blank area has fired.

Is it possible that I'm retreating from the print event and the entire
"overflow" page is being re-formatted? That's the only thing I can think
of.

Should I implement a "retreat" event for that little blank area where I set
the page number page to where it was before I made it a zero?


I don't think it's that complicated. Not sure, but a
possible(?) reason for it not working on some pages is
because small blank space is split across a page boundary.
Regardless, the group foogter section needs to have it's
KeepTogether property set to Yes.

I would approach this a little differently. First, make the
special group footer invisible or set it's Height to 0.
Second, remove the code for the page header. Then use the
report header Print event to make the page header section
invisible:
Me.Section(2).Visible = False
and put the same line in your group footer's Print event.

Add a line in the group header's Print event to make it
visible again:
Me.Section(2).Visible = True
and make sure the group header section's ForceNewPage
property is set to Before Section
 
I see what you're getting at, but I think the group footer print event won't
fire if the group footer height is zero (or not visible). It's detected at
the time the group footer is formatted that there's nothing to print.

The group footer (the special one with the little blank space) is not
causing the page to overflow since all the receipts in the test run are 2
pages long anyway. The place where the footer prints is about halfway down
on the second page.

And the height of that footer is.0007" ... which is the smallest allowed.
So it's not likely that it'll cause a page overflow even if the situation
could even occur where it would be exactly at the bottom of the page.

I think I'll give the idea of saving the page number in the footer print
event (before I set it to zero) and restoring it in a retreat event (I don't
have a retreat event right now, but I'll make one for this test).

And I'll keep you posted.

bob
 
Actually, it was something else. My logic was correct, but I had an error
in another spot. Data for THE PRIOR receipt was making is past the filter,
but I was then deleting the detail records because I determined they should
not print. I ended up deleting all detail records for the account
immediately preceeding the one where the page didn't overflow correctly.
And this messed up the logic.

I'll work on my filter to broaden its scope somehow ... or at least figure
out how to cope with this situation.

Thanks...

bob
 
You're right, my bad. That should be the group footer
Format event. I also had the wrong section number, the page
header is Section 3.

Sorry for making a hash of it. I have done this dozens of
times and should not make silly mistakes like that.
 
That's ok ... I fixed my "filtering problem" and it's now working. Except
for something else that I'll start a new thread for ... there's one extra
blank line on the report. bob

Marshall Barton said:
You're right, my bad. That should be the group footer
Format event. I also had the wrong section number, the page
header is Section 3.

Sorry for making a hash of it. I have done this dozens of
times and should not make silly mistakes like that.
--
Marsh
MVP [MS Access]


Bob said:
I see what you're getting at, but I think the group footer print event
won't
fire if the group footer height is zero (or not visible). It's detected
at
the time the group footer is formatted that there's nothing to print.

The group footer (the special one with the little blank space) is not
causing the page to overflow since all the receipts in the test run are 2
pages long anyway. The place where the footer prints is about halfway
down
on the second page.

And the height of that footer is.0007" ... which is the smallest allowed.
So it's not likely that it'll cause a page overflow even if the situation
could even occur where it would be exactly at the bottom of the page.

I think I'll give the idea of saving the page number in the footer print
event (before I set it to zero) and restoring it in a retreat event (I
don't
have a retreat event right now, but I'll make one for this test).


"Marshall Barton" wrote
 
Back
Top