Not print group header when group footer prints

  • Thread starter Thread starter Kate
  • Start date Start date
K

Kate

Hi, I have a report that contains the column headings for the detail
data in the group header, repeating at the top of each page. This is
because I have a subreport printing in the group footer, which has its
own different headings. I have a page break occurring before the group
footer, but can't figure out how to make the group header not print on
pages where the group footer prints.

Thanks in advance,
Kate
 
Kate said:
Hi, I have a report that contains the column headings for the detail
data in the group header, repeating at the top of each page. This is
because I have a subreport printing in the group footer, which has its
own different headings. I have a page break occurring before the group
footer, but can't figure out how to make the group header not print on
pages where the group footer prints.


I have always thought that there is no way to do that. Ever
since the RepeatSection property was intorduced, it has not
been able to deal with being displayed conditionally.

In A97, making the header invisible in its format event or
cancelling the format event sent the report into an infinite
loop.

In AXP, it seems as if MS added some code to prevent the
loop, but they did it with the simple expedient of turning
the RepeatSection property off (even though we can't change
it while the report is running) when the header section
tries to make itself invisible or cancel is set to true IN
THE FORMAT EVENT.

However, while playing around, I found that if you use the
print event to Cancel the event it seems(?) to work. Here's
the code logic I used in case you want to try it (NO
GUARANTEE):

Add an invisible text box named txtRecCnt to the group
header section and set its control source expression to
=Count(*)

Add an invisible text box named txtLineNum to the detail
section. Set its control source expression to =1 and it
RunningSum property to Over Group

**** Code in the report's module****
Dim bolLastDetail As Boolean

Private Sub Detail_Print(Cancel As Integer, PrintCount As
Integer)
bolLastDetail = (Me.txtLineNum = Me.txtRecCnt)
End Sub

Private Sub GroupFooter1_Print(Cancel As Integer, PrintCount
As Integer)
bolLastDetail = False
End Sub

Private Sub GroupHeader0_Print(Cancel As Integer, PrintCount
As Integer)
Cancel = bolLastDetail
End Sub

I do not have A2K and have not tried this in A2003 so I can
not state how those versions deal with this situation.
 
Marshall, I've been trying what you suggested plus other variations
because it didn't work. Haven't succeeded yet.

The complication is that there is another group inside the top
group(0), so that the detail count keeps resetting when summing over
group. This is the setup:

Groupheader(0)
Groupheader(1)
detail
Groupfooter(0)
subreport, with its own headings

Thanks for your help, I'll keep working at it (maybe...I've managed to
format the report so that some of the detail prints on the page where
the subreport prints, so each has its own heading and doesn't look too
weird).

-Kate
 
It get messier with multiple levels, so I'm not surprised
you haven't succeeded yet.

To get a running line number of details across two levels
you need to add two text boxes to groupheader(1)

txtGrp1Cnt: =Count(*) RunningSum - No
txtRunGrp1Cnt: =Count(*) RunningSum - Yes

and add another text box to the detail section

txtRunLineNum: =[txtRunGrp1Cnt]-[txtGrp1Cnt]+[txtLineNum]
RunningSum - No

Then change the code in the detail section's Print event to:

bolLastDetail = (Me.txtLineNum = Me.txtRecCnt)

Note that there is no way to reclaim the space used by the
repeating header section. Access won't let you do cancel
the header in the Format event and the consumed space can
not be changed in the Print event.
 
Marshall, thanks for all you help. The numbers add up correctly now,
but the header still prints. I'm giving it up. What I've finally
resorted to now is the cheater method: if the page number equals 11
or 23 (where I'm printing the subreports), I cancel the first header.

-Kate
 
Oops. What I meant to say was:

Public lngSubHeadCnt As Long

Private Sub GroupHeader0_Print(Cancel As Integer, PrintCount As Integer)
lngSubHeadCnt = PrintCount + lngSubHeadCnt
If lngSubHeadCnt = 11 Or lngSubHeadCnt = 23 Then Cancel = True
End Sub


Marshall, thanks for all you help. The numbers add up correctly now,
but the header still prints. I'm giving it up. What I've finally
resorted to now is the cheater method: if the page number equals 11 or
23 (where I'm printing the subreports), I cancel the first header.

-Kate

Marshall said:
It get messier with multiple levels, so I'm not surprised
you haven't succeeded yet.

To get a running line number of details across two levels
you need to add two text boxes to groupheader(1)

txtGrp1Cnt: =Count(*) RunningSum - No
txtRunGrp1Cnt: =Count(*) RunningSum - Yes

and add another text box to the detail section

txtRunLineNum: =[txtRunGrp1Cnt]-[txtGrp1Cnt]+[txtLineNum]
RunningSum - No

Then change the code in the detail section's Print event to:

bolLastDetail = (Me.txtLineNum = Me.txtRecCnt)

Note that there is no way to reclaim the space used by the
repeating header section. Access won't let you do cancel
the header in the Format event and the consumed space can
not be changed in the Print event.
 
Back
Top