Follow up to Page Breaks

D

Darrell

Just one more issue as a followup to the last post regarding Page Breaks.
In a report where I have a group header with a group footer and a new
page forced for each change of the group header, I would like to combine
this with a page header where the current group header value repeats.
Simply placing the group header value in a page header accomplishes
this. HOWEVER, there is one major caveat. This value ALSO repeats on
pages where the value CHANGES, which places this value at the top of the
page already. So... you end up with something like this:

Group Header Value 1 (from page header)
Group Header Value 1 (from group header)
--- Page Break ---
Group Header Value 1 (from page header)
--- Page Break ---
Group Header Value 2 (from page header)
Group Header Value 2 (from group header)
--- Page Break ---
Group Header Value 2 (from page header)
--- Page Break ---

etc. ...

The trick is to get the Group Header Value to repeat ONLY on pages that
do NOT coincide with a Group Header Value CHANGE...

Again, any ideas would be greatly appreciated.

Darrell
 
M

Marshall Barton

Darrell said:
Just one more issue as a followup to the last post regarding Page Breaks.
In a report where I have a group header with a group footer and a new
page forced for each change of the group header, I would like to combine
this with a page header where the current group header value repeats.
Simply placing the group header value in a page header accomplishes
this. HOWEVER, there is one major caveat. This value ALSO repeats on
pages where the value CHANGES, which places this value at the top of the
page already. So... you end up with something like this:

Group Header Value 1 (from page header)
Group Header Value 1 (from group header)
--- Page Break ---
Group Header Value 1 (from page header)
--- Page Break ---
Group Header Value 2 (from page header)
Group Header Value 2 (from group header)
--- Page Break ---
Group Header Value 2 (from page header)
--- Page Break ---

etc. ...

The trick is to get the Group Header Value to repeat ONLY on pages that
do NOT coincide with a Group Header Value CHANGE...


Two ideas. If your group header displays the same
information as the page header, then get rid of the page
header and set the group header's RepeatSection property to
Yes.

If the page header is different from the group header and
you don't want to see the page header at the start of the
group, use the group footer section's Format event to make
the page header invisible:
Me.Section(4).Visible = False
and use the group header section's Format event to make it
visible for any subsequent pages in the group.
 
D

Darrell

Marshall said:
Two ideas. If your group header displays the same
information as the page header, then get rid of the page
header and set the group header's RepeatSection property to
Yes.

If the page header is different from the group header and
you don't want to see the page header at the start of the
group, use the group footer section's Format event to make
the page header invisible:
Me.Section(4).Visible = False
and use the group header section's Format event to make it
visible for any subsequent pages in the group.
Marshall,

Thanks for the suggestions. The second one is what I jumped for in my
head until I realized that I want to have the page header value reflect
the current group header value. Why, you ask? Well... just because I
wanted the first instance of the group header to be in a larger font,
and the subsequent instances in a smaller one...

My co-worker suggested using the group header/group footer combination
to start and reset a counter which could then be used to change the font
of the group header. So, with a combination of ideas I might whip this yet.

Thanks again,
Darrell
 
M

Marshall Barton

Darrell said:
Marshall,

Thanks for the suggestions. The second one is what I jumped for in my
head until I realized that I want to have the page header value reflect
the current group header value. Why, you ask? Well... just because I
wanted the first instance of the group header to be in a larger font,
and the subsequent instances in a smaller one...

My co-worker suggested using the group header/group footer combination
to start and reset a counter which could then be used to change the font
of the group header. So, with a combination of ideas I might whip this yet.


So the page header is different from the group header, even
if it's just the bold setting. The second approach I
suggested should take care of that situation easily.

You already have the grouping field on the page header so
that's not an issue. I guess I don't see why you would need
any other complications? If it's that you do not have a
group footer, create it and make it invisible, its event
will still be effective.
 
D

Darrell

Marshall said:
So the page header is different from the group header, even
if it's just the bold setting. The second approach I
suggested should take care of that situation easily.

You already have the grouping field on the page header so
that's not an issue. I guess I don't see why you would need
any other complications? If it's that you do not have a
group footer, create it and make it invisible, its event
will still be effective.
Sorry, Marsh,
I know I'm obtuse sometimes... If I use a page header, I don't know of
any way to make it recognize when the group header has changed. I have
quite a bit of additional information in the group header which I don't
want to repeat. And, I want at the top of every page to say "ReportName
(cont.)" So, I can't use a page header which I make visible and
invisible. Now, this is going to get convoluted so hang on...
I have eliminated the page header altogether and have used a second
group header on the exact same data as the first, the first with the
group title, if you will, and the "... (cont.)" piece, and the second
with the additional information about that group; and, since the format
event of both headers fires everytime the group changes, I need a way to
bold the title sometimes and not other times. Thus the counter which
gets reset when the footer format event fires and tested each time the
first group header format event fires.

There, I'm tired; I don't know about you. But that's the only way I've
been able to get it to work.

Am I missing the simple in the forest of the complex?

Thanks for your time.

Darrell
 
M

Marshall Barton

Darrell said:
I know I'm obtuse sometimes... If I use a page header, I don't know of
any way to make it recognize when the group header has changed. I have
quite a bit of additional information in the group header which I don't
want to repeat. And, I want at the top of every page to say "ReportName
(cont.)" So, I can't use a page header which I make visible and
invisible. Now, this is going to get convoluted so hang on...
I have eliminated the page header altogether and have used a second
group header on the exact same data as the first, the first with the
group title, if you will, and the "... (cont.)" piece, and the second
with the additional information about that group; and, since the format
event of both headers fires everytime the group changes, I need a way to
bold the title sometimes and not other times. Thus the counter which
gets reset when the footer format event fires and tested each time the
first group header format event fires.

There, I'm tired; I don't know about you. But that's the only way I've
been able to get it to work.

Am I missing the simple in the forest of the complex?


Well, this is more complex than I perceived from your
previous posts. Your idea of using two group headers might
be very helpful.

Using counter to getting a "(cont.)" on a group header's
second page is a good idea. However, I want to add a
warning about counters, do not, under any circumstances, use
code in an event procedure to do the counting. Instead, use
a running sum text box with =1 as its expression.
 
D

Darrell

Marshall said:
Well, this is more complex than I perceived from your
previous posts. Your idea of using two group headers might
be very helpful.

Using counter to getting a "(cont.)" on a group header's
second page is a good idea. However, I want to add a
warning about counters, do not, under any circumstances, use
code in an event procedure to do the counting. Instead, use
a running sum text box with =1 as its expression.
Really!? Okay. Thanks for the tip. Out of curiosity, why? Is there
something unreliable about the code method? (In case you haven't guessed
it, the code method was precisely what I was doing.)

Thanks again,
Darrell
 
M

Marshall Barton

Darrell said:
Really!? Okay. Thanks for the tip. Out of curiosity, why? Is there
something unreliable about the code method? (In case you haven't guessed
it, the code method was precisely what I was doing.)

The code method is rather intuitive and most people fall
into the trap. It was a long and painful experience before
I figured out what was happening. It's not that there's
anything wrong with event procedures, it's just that the
sections are processed whenever and in whatever order is
needed to format the report. Think about what might happen
if you have a section's or group's KeepTogether property
set. The section or an entire group must be formatted (with
all events triggered) just to determine that if won't fit on
the current page. Then a new page is started and the entire
section or group's processing starts over. Using the Pages
property in a text box causes the entire report to be
processed twice so a code counter will be at least double
the expected value. In Preview view, navigating to the last
page can skip formatting some parts of the report so the
count may be lower than expected.
 
D

Darrell

Marshall said:
The code method is rather intuitive and most people fall
into the trap. It was a long and painful experience before
I figured out what was happening. It's not that there's
anything wrong with event procedures, it's just that the
sections are processed whenever and in whatever order is
needed to format the report. Think about what might happen
if you have a section's or group's KeepTogether property
set. The section or an entire group must be formatted (with
all events triggered) just to determine that if won't fit on
the current page. Then a new page is started and the entire
section or group's processing starts over. Using the Pages
property in a text box causes the entire report to be
processed twice so a code counter will be at least double
the expected value. In Preview view, navigating to the last
page can skip formatting some parts of the report so the
count may be lower than expected.
AhHaaahhh... Could it be that THAT is why I just puzzled over why a
report format section seemed to be firing twice for each instance of the
grouped value... That is a distinct possibility...

So, pardon my ignorance yet again... How, exactly, would I structure a
RunningSum to check for the first occurrence of a section header (set to
repeat) vs. subsequent occurrences? I couldn't seem to apply the help
(it's explanation was too brief for me).

I would have...
Group Header
textboxheader with controlsource = 1
Group Footer
textboxfooter with controlsource = textboxheader and RunningSum set to
true?

I'm groping here, Sorry.

Darrell
 
M

Marshall Barton

Darrell said:
AhHaaahhh... Could it be that THAT is why I just puzzled over why a
report format section seemed to be firing twice for each instance of the
grouped value... That is a distinct possibility...

So, pardon my ignorance yet again... How, exactly, would I structure a
RunningSum to check for the first occurrence of a section header (set to
repeat) vs. subsequent occurrences? I couldn't seem to apply the help
(it's explanation was too brief for me).


For reasons I would rather not go into, you can not count
the number of times a header section repeats that way. The
trick is to count the details and check if the header is for
the first detail.

Detail section

text box Name txtCounter
ControlSource =1
RunningSum Over Group

Code in group header section's Format event:

If txtCounter = 1 Then
' code for first header in this group
Me.txtContinued.Visible = False
Me.txtGroupId.FontBold = True
Else
' code for subsequent headers in this group
Me.txtContinued.Visible = True
Me.txtGroupId.FontBold = False
End If
 
D

Darrell

Marshall said:
For reasons I would rather not go into, you can not count
the number of times a header section repeats that way. The
trick is to count the details and check if the header is for
the first detail.

Detail section

text box Name txtCounter
ControlSource =1
RunningSum Over Group

Code in group header section's Format event:

If txtCounter = 1 Then
' code for first header in this group
Me.txtContinued.Visible = False
Me.txtGroupId.FontBold = True
Else
' code for subsequent headers in this group
Me.txtContinued.Visible = True
Me.txtGroupId.FontBold = False
End If
Marsh,
I was developing a sneaking suspicion of that (I couldn't for the life
of me figure out what it was going to count). The above solution was
sort of swimming around in my head a bit vaguely formed (that happens a
lot to me...). But, a hurdle to thinking it through was that the way I
had the report structured (with "detail" records being written to text
boxes programmatically) there was no need for a detail section, so there
were no controls in it. It will, however, work with moving some controls
into the detail section and adding that text box. In fact, I could
probably add that text box as the ONLY control in the detail section,
couldn't I? Sorry, I'm thinking out loud, but, yes... I think I can get
this to work.

Thanks so much, and I'll let you know the results.

Hmhmmm... If you have time, you might also have a look at my post
regarding alternating margins (users are never satisfied you know) from
yesterday. I'm making progress with Fred's help, but just might welcome
your input as well. Thanks again for your time.

Darrell
 

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