Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Apr 2001
    Location
    Joliette, Quebec, Canada
    Posts
    290
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Group counter (97 sr2 )

    I have a report that has two headers , I want a counter that only displays the line number of the primary header, and does not reset when the value of the second header changes. So if I have 300 cases, each with 100 cases in the primary header the line display will go from 1 to 100 three times, rather that resetting when the value of the second header changes (which is about 10 times).
    I have not thank everyone who has helped me in the past, so I wish to do so and wish you all a happy Chinese new year.

    Richard

  2. #2
    3 Star Lounger
    Join Date
    Dec 2001
    Location
    Schenectady, New York, USA
    Posts
    273
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Group counter (97 sr2 )

    Richard,

    Set a counter in your declare area and then set the counter to zero in the format of the header. Add one to the counter to the on each detail format. Place a textbox on the report and have the textbox = the line counter after it is incremented each time.

    Option Compare Database
    Dim LineCntr As Long

    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

    LineCntr = LineCntr + 1
    Me.lineNo = LineCntr

    End Sub

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

    LineCntr = 0

    End Sub


    See the attached
    Attached Files Attached Files
    Don
    <img src=/S/flags/USA.gif border=0 alt=USA width=30 height=18> <img src=/S/flags/NewYork.gif border=0 alt=NewYork width=30 height=18> "Life on Earth is expensive, but at least it includes a free trip around the Sun."

  3. #3
    New Lounger
    Join Date
    Jan 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Group counter (97 sr2 )

    DJLansing's approach will work, but be careful if your intent is for the user of the report to DISPLAY rather than printing the report.

    If you want to user to view the report, you will want to add a mechanism to zero the counter after the report is complete, otherwise it continues to accumulate as it is a global variable.

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Group counter (97 sr2 )

    Only variables declared public in a standard module, not forms or reports, are global variables. In this case, the variable is declared as module level and is being zeroed out in the GroupHeader, which comes before anything in Detail. <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

    There is a gotcha in here, though. If the GroupHeader is set to repeat when the group spans pages, the numbering would restart on each page. Resetting the variable to zero in the report header rather than the GroupHeader would take care of that.
    Charlotte

Posting Permissions

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