Results 1 to 4 of 4
  1. #1
    shank is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Sep 2010
    Posts
    188

    Conditional Page Breaks

    I need a page break after 5 records. I inserted a page break and made it invisible.

    Code:
    Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As Integer)
    Me![PageBreak62].Visible = False
    End Sub
    See below. Then I setup up the condition to make the page break visible. Results not as expected. I added a textbox [RecCounter] that counts each record 1, 2, 3, 4, etc. In my test example I have a total of 10 records.

    1) I would expect the page break to work if >5. But I need > 4 for it to create a page break after 5 records. Just curious, why doesn't >5 work for 5 records.

    2) The page breaks after 5 records, but all pages thereafter have 1 record per page because the [RecCounter] doesn't reset to count 1, 2, 3, etc. It's still counting the Running Sum Over All. I set it to Count Over the Group, but still it counts 0-10 on all 10 records. So, how do I get it to only count the records on that page?



    Code:
    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    If Me![RecCounter] > 4 Then
            Me![PageBreak62].Visible = True
        End If
    End Sub
    thanks!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Try this:

    Code:
      If Me.RecCounter Mod 5 = 0 Then
        Me.PageBreak62.Visible = True
      Else
        Me.PageBreak62.Visible = False
      End If
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    shank is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Sep 2010
    Posts
    188
    That worked. Thanks! Could you elaborate in layman's terms how that worked? I googled for Mod use in VB and still not quite understanding. Is my thinking in the below statements correct?

    If Me.RecCounter Mod 5 = 0 Then

    Assume RecCounter = 1, 2, 3, or 4
    RecCounter/5 has a remainder which means not 0 Then PageBreak62 remains invisible, correct?

    Assume RecCounter = 5
    RecCounter/5 has no remainder which means 0 Then PageBreak62 is now visible, correct?

    Assume RecCounter = 6, 7, 8, or 9
    RecCounter/5 (repeatedly) has a remainder which means not 0 Then PageBreak62 remains invisible, correct?

    Assume RecCounter = 10
    RecCounter/5 (twice) has no remainder which means 0 Then PageBreak62 is now visible, correct?


    thanks!

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    You've got it. If the number is evenly divisible by 5 there is no remainder. In that event the condition is met so the page break is visible, otherwise not.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Page Breaks
    By keiath in forum Reports
    Replies: 6
    Last Post: 01-22-2014, 05:38 PM
  2. Forms - Using page breaks
    By TeaBase in forum Forms
    Replies: 7
    Last Post: 11-06-2013, 11:59 AM
  3. Page Breaks
    By Talayoe in forum Reports
    Replies: 2
    Last Post: 11-26-2012, 11:20 AM
  4. Page breaks
    By berni3883 in forum Reports
    Replies: 0
    Last Post: 03-31-2011, 01:25 PM
  5. Page Breaks. Is there a way to do it?
    By newtoAccess in forum Reports
    Replies: 8
    Last Post: 11-30-2010, 01:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums