Results 1 to 4 of 4
  1. #1
    jezzamax is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2010
    Posts
    3

    Figure Numbers incrementing over Page Breaks

    I have a subreport which displays a simple title and text field. There is also code in the Detail_Print event that creates a figure number by calling a function GetNewFigNum() which simply increments a global variable intFigCounter by 1.



    Works fine, except when the subreport is called by the main report, and the subreport goes over a page break, then the code in the Detail_Print event gets called twice and intFigCounter gets incremented again.

    How can I handle the page break problem?

  2. #2
    apr pillai's Avatar
    apr pillai is offline Competent Performer
    Windows XP Access 2003
    Join Date
    May 2010
    Location
    Alappuzha, India
    Posts
    209
    Check the Format Count value to prevent incrementing the variable twice:

    Code:
    if formatcount = 1 then
      intFigCounter=intFigCounter+1
    end if

  3. #3
    jezzamax is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2010
    Posts
    3
    OK - I have used the FormatCount value as suggested and this works perfectly if you just look at the SubReport in Print Preview.

    BUT when I print preview the main report, the figure numbers generated in the sub-report still increment when there is a page break.

    The code I am using is below :

    Code:
     
    Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer) 
    If FormatCount = 1 Then
      If Me.chkHasFigure = True Then
        Me.txtFigNum = GetNewFigNum()
        Me.txtFigRefer = "Refer to Figure " & Me.txtFigNum & "."
        Call UpdateToc("Figure " & Me.txtFigNum & ". " & Me.txtFigureCaption)
      End If
    End If
    End Sub

  4. #4
    jezzamax is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2010
    Posts
    3
    Actually I have just figured this out. I changed FormatCount to PrintCount anbd eveything is working

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

Similar Threads

  1. Incrementing a value in a form
    By erbuchan in forum Access
    Replies: 10
    Last Post: 01-26-2011, 12:33 AM
  2. Page Breaks. Is there a way to do it?
    By newtoAccess in forum Reports
    Replies: 8
    Last Post: 11-30-2010, 01:02 PM
  3. Calculating Beginning and Ending page numbers
    By sabraham in forum Access
    Replies: 3
    Last Post: 01-07-2010, 12:36 PM
  4. Custom & Auto Incrementing Job Number
    By mastromb in forum Programming
    Replies: 1
    Last Post: 01-05-2010, 02:58 PM
  5. Can't Figure It Out!!
    By jdohio5 in forum Database Design
    Replies: 1
    Last Post: 05-04-2006, 06:49 AM

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