force a page break with VBA

F

Fay

I am trying with VBA to force a page break on a group if a control is not
checked. The checkbox default setting is -1 forcing the user to manually
change it for a run on report. I don't get any error messages with this code
but neither do I get the three departments to print on one page. Thank you
for your assistance.

Private Sub GroupHeader0_Format(Cancel As Integer, FormatCount As Integer)
Dim intGetVal As Integer

If [Forms]![frmReports]![chkForceBreak] = -1 Then
intGetVal =
[Reports]![rptStaffListingByUnit].Section(acDetail).ForceNewPage = 1
End If
End Sub
 
W

Wayne Morgan

intGetVal =
[Reports]![rptStaffListingByUnit].Section(acDetail).ForceNewPage = 1

It appears the above wrapped, but if it's not all one line then you would
get an error. If it is all one line, you are assigning True (-1) or False
(0) to the value of intGetVal. A better way to write this to see what is
actually happening would be

intGetVal =
([Reports]![rptStaffListingByUnit].Section(acDetail).ForceNewPage = 1)

The part in the parenthesis will return True or False. This is not setting
the ForceNewPage option, it is checking to see if the ForceNewPage option is
set to 1. Instead, to set the ForceNewPage option, the equation should be:

[Reports]![rptStaffListingByUnit].Section(acDetail).ForceNewPage = 1


If that doesn't work, the Format event of the group header may be too late
to do this. Try doing this in the report's Open event.

--
Wayne Morgan
MS Access MVP


Fay said:
I am trying with VBA to force a page break on a group if a control is not
checked. The checkbox default setting is -1 forcing the user to manually
change it for a run on report. I don't get any error messages with this
code
but neither do I get the three departments to print on one page. Thank you
for your assistance.

Private Sub GroupHeader0_Format(Cancel As Integer, FormatCount As Integer)
Dim intGetVal As Integer

If [Forms]![frmReports]![chkForceBreak] = -1 Then
intGetVal =
[Reports]![rptStaffListingByUnit].Section(acDetail).ForceNewPage = 1
End If
End Sub
 

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