Force new page

P

Phil

HI,

I have a form with a command button that previews a report
with a group on teachers and a group heading
called "GroupHeader2".

I want to place a check box on the form called "ckNewPage"
which if checked will cause the report to force a new page
for each teacher. What code would I use and where would
it go? I've tried many things but no success....

Thanks,
Phil
 
A

Allen Browne

Use the Open event of the report to read the check box (if the form is
open), and set the ForceNewPage property of the group header:

Private Sub Report_Open(Cancel As Integer)
Const conNewPageBefore As Byte = 1

If CurrentProject.AllForms("NameOfYourFormHere").IsLoaded Then
If (Forms("NameOfYourFormHere")!chNewPage.Value) Then
Me.Section(acGroupLevel1Header).ForceNewPage = conNewPageBefore
End If
End If
End Sub


Note: Access 97 and earlier do not have the AllForms collection. For those
versions, copy the IsLoaded() function from the Northwind sample database,
and use that instead.
 
Top