ACC2000: How to Repeat Subreport Header at Top of PageID: Q231808
|
This article describes how to repeat a subreport's header when the subreport spans multiple pages.
NOTE: This method works best for one subreport. Attempting to repeat
the subreport header for multiple subreports requires a set of controls in the page header and a flag for each subreport. Then the code must check each flag and hide or show the appropriate sets of controls. This code is not easy to maintain.
The method demonstrated in the following example uses a flag in the page
header to indicate whether the subreport spans multiple pages. When the
subreport's report header is printed, the flag is set to 1. When the
subreport's report footer is printed, the flag is set to 0. When the page
header is printed, if the flag is set to 1, then the subreport spans
multiple pages and the subreport's header should be repeated.
The following example demonstrates how to cause a subreport's header to be
repeated if the subreport spans multiple pages:
Macro Name Condition Action
------------------------------------
MainRH SetValue
MainPH [Flag]=0 CancelEvent
SubRH SetValue
SubRF SetValue
MainRH Actions
------------------------------------------------
SetValue
Item: Reports![Categories Main Report]![Flag]
Expression: 0
SubRH Actions
------------------------------------------------
SetValue
Item: Reports![Categories Main Report]![Flag]
Expression: 1
SubRF Actions
------------------------------------------------
SetValue
Item: Reports![Categories Main Report]![Flag]
Expression: 0
Text Box:
Name: ProductID
ControlSource: ProductID
Text Box:
Name: CategoryID
ControlSource: CategoryID
Text Box:
Name: ProductName
ControlSource: ProductName
Label:
Name: Text1
Caption: ProductID
Label:
Name: Text2
Caption: CategoryID
Label:
Name: Text3
Caption: ProductName
RepeatSubHeader.SubRH
RepeatSubHeader.SubRF
Text Box:
Name: Flag
Visible: No
Text Box:
Name: CategoryID
ControlSource: CategoryID
Text Box:
Name: CategoryName
ControlSource: CategoryName
Text Box:
Name: Description
ControlSource: Description
RepeatSubHeader.MainRH
RepeatSubHeader.MainPH
Macro Name Condition Action
------------------------------------------------------
MainPH [Flag]=0 SetValue
Item: [Text1].visible
Expression: False
... SetValue
Item: [Text2].visible
Expression: False
... SetValue
Item: [Text3].visible
Expression: False
[Flag]=1 SetValue
Item: [Text1].visible
Expression: True
... SetValue
Item: [Text2].visible
Expression: True
... SetValue
Item: [Text3].visible
Expression: True
For more information about events during printing, click Microsoft Visual Basic Help on the
Help menu, type "Print Events" in the Office Assistant or the Answer Wizard,
and then click Search to view the topics returned.
For more information about report OnFormat and OnPrint properties, click Microsoft Visual Basic Help on the
Help menu, type "OnFormat and/or OnPrint" in the Office Assistant or the Answer Wizard,
and then click Search to view the topics returned.
Additional query words:
Keywords : kbusage kbdta RptSub
Version : WINDOWS:2000
Platform : WINDOWS
Issue type :
Last Reviewed: June 10, 1999