Results 1 to 5 of 5
  1. #1
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    NJ, USA
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    forcing new page on header with VBA (Access03)

    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
    Else
    intGetVal = [Reports]![rptStaffListingByUnit].Section(acDetail).ForceNewPage = 0
    End If
    End Sub

    Fay

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: forcing new page on header with VBA (Access03)

    A line such as

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

    doesn't set the ForceNewPage property, it only compares its value to 1, and assigns the result (True if is 1, False otherwise) to intGetVal. So nothing happens. You only have to set the property once, when the report opens, so instead of the On Format event of GroupHeader0, I would use the On Open event of the report:

    Private Sub Report_Open(Cancel As Integer)
    Me.Section(acDetail).ForceNewPage = -[Forms]![frmReports]![chkForceBreak]
    End Sub

    Note that you can refer to the report as Me in its own module.

  3. #3
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    NJ, USA
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: forcing new page on header with VBA (Access03)

    Thank you Hans. This almost works it splits at the detail level and I need it to split at the GroupHeader0 level. I exchanged GroupHeader0 and acGroupHeader0 for acDetail, but those didn't work. Fay

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: forcing new page on header with VBA (Access03)

    If it's the first group header, try acGroupLevel1Header; and if it's the second group header, try acGroupLevel2Header.

  5. #5
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    NJ, USA
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: forcing new page on header with VBA (Access03)

    Thanks Hans level 1 did it. I had searched on GroupHeader not GroupLevelHeader. That kind on issues is that I thinks makes it complicated to get the job. But with yours and others help I am getting where I want to go. Thank you. Fay

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •