Function ForceSectionToNewPage(StrReportName As String, iCurrentGroupHeader As Integer)
Dim sHeight As Single
Dim I As Integer
Dim PrtMipString As str_PRTMIP
Dim PM As type_PRTMIP
Dim R As Report
On Error GoTo Ooops
Set R = Reports(StrReportName)
PrtMipString.strRGB = R.PrtMip
LSet PM = PrtMipString
With R 'Summing reports and page sections heights
sHeight = PM.yTopMargin
For I = 1 To iCurrentGroupHeader
sHeight = sHeight + .Section(I * 2 + 1).Height
Next I
If (.top > (sHeight + 5)) And (.Page <> 1) Then
.MoveLayout = True
.PrintSection = False
.NextRecord = False
End If
End With
ExitForceSectionToNewPage:
StrReportName = ""
Set R = Nothing
Exit Function
Ooops:
DoCmd.Beep
DoCmd.Echo True
DoCmd.Hourglass False
MsgBox "Um erro aconteceu na função ForceSectionToNewPage: " & Error$
Resume ExitForceSectionToNewPage
End Function