How do I reset page number for each record in dataset

Posted by: prescott.chartier on 5 December 2022, 1:11 pm EST

    • Post Options:
    • Link

    Posted 5 December 2022, 1:11 pm EST - Updated 5 December 2022, 1:37 pm EST

    I have a 7 page report which executes just fine, but I need to reset the page number to page 1 after each record is processed. Is there anyway to do that?

    My code:

                rpt = New NEYTFContract
                rpt.WatermarkSizeMode = GrapeCity.ActiveReports.SectionReportModel.SizeModes.Zoom
                rpt.DataSource = MyDataSet
                rpt.DataMember = "Data"

    As I had said, the report runs fine with no issues, its just that after page 7 I need to reset the page counter to 1 for the next record.


    Prescott …

  • Posted 5 December 2022, 10:41 pm EST - Updated 6 December 2022, 3:05 pm EST

    Hi Prescott,

    You can add a custom page number variable in your script and increment it for each time the PageHeader/PageFooter’s Format event is called and reset it on the Detail section’s Format event then you can use this page number variable in your page footer/header.

    Based on the above approach, I have created a sample application and attached it along with for reference. In the sample application I have set the Detail Section’s NewPage property to **After **so each detail sections begins on a new page.

    To learn more on Report Event’s please refer to the following page of our documentation:

  • Posted 6 December 2022, 3:44 am EST

    Ok, that’s almost got me there. I add the following to my code:

    Public Class MyReport
        Dim Mypagenumber As Integer
        Private Sub Detail_Format(sender As Object, e As EventArgs) Handles Detail.Format
            Mypagenumber = 1
        End Sub
        Private Sub PageFooter1_Format(sender As Object, e As EventArgs) Handles PageFooter1.Format
            Label_Pagenumber.Text = "Page " & Mypagenumber.ToString() & " of 7"
            Mypagenumber = Mypagenumber + 1
        End Sub
    End Class

    The label in the header is set to “Page 1 of 7” to begin and what I get is on page 2 the page is set to 1 and is incremented for each page where page 1 of the second record is set to page 7 of 7. I’ll play around with it until I get what I want but I think I’m on the right track.


    Prescott …

  • Posted 6 December 2022, 4:14 am EST

    Just can’t seem to get it. I’ve tried all settings, pagefoorter before, after, or none. I tried pageheader, with all the new page setting and I just can’t get page 1 set to 1 and then increment the page number until I get to the second record and reset to 1 again. I either get “Page 0 0f 7” for page 1 or two “Page 1 of 7”'s, or I get “Page 2 of 7” on the first page of the second record. Very frustrating.


    Prescott …

  • Posted 6 December 2022, 9:17 am EST


    I obviously don’t understand the event sequence as nothing I do changes the fact that (apparently) the detail format section is NOT being executed for the first record in the dataset. So I figured I’d look at the link you provided, no luck there either as it would seem that the link at doesn’t exist. Is there another link? I can’t find anything.


    Prescott …

  • Posted 6 December 2022, 6:27 pm EST

    Hi Prescott,

    I have fixed the issue with the link in in my previous reply. Here’s the link again:

    If you are still not able to open the link then just open our documentation ActiveReports 16 User Guide then go to Concepts>Section Report Concepts>Section Report Events for information on the Section Report events.

    As for the issue that you are facing, please share a runnable sample application replicating this issue or edit the previously attached sample such that it reproduces this issue and send it back to us so we can replicate this behavior at our end and investigate further on this. Bare minimum we would require a sample section report and dummy data so we can render report and reproduce this issue. If you are using Code-based Section Reports then you will have to share the .vb,.designer.vb and .resx files and if you are using XML based Section Reports then you would have to share the .rpx file.

    Otherwise, If you are creating the report object at runtime and do not have the report files then you can save the report layout using report.SaveLayout method to save the report as XML based Section Report(.rpx file).

    Other then the report file make sure to share a sample data set so we can reproduce this issue exactly as you are observing in your application.

  • Posted 7 December 2022, 4:55 am EST

    Well, wouldn’t you know it, it suddenly started working. No idea how or what was causing it not to work, but now the pages are numbered correctly from 1 to n records. I’m baffled because I didn’t really do anything. I was trying different things to see the effect and I set everything back to the original code you provided and now it works. No clue. Another thing that I find to be extremely frustrating. I have to KNOW what was wrong, but I suspect that I won’t lose much sleep over it. Sigh …

    Well, I did add one line of code in the detail format section, see below:

        Private Sub Detail_Format(sender As Object, e As EventArgs) Handles Detail.Format
                Label_Pagenumber.Text = "Page 1 of 7"
                Mypagenumber = 1
       End Sub

    But that’s it, just the one line. everything else is the same.

    Just so you know, I’m using Visual Studio 2013 and Active Reports v11, not that it should matter much in respects to the event order I suspect, I do have Visual Studio 2022 but Active Reports v11 doesn’t work with that version and I can’t justify the upgrade cost, so that’s what I’m stuck with.


    Prescott …

  • Posted 7 December 2022, 5:43 pm EST

    Hi Prescott,

    I totally understand this could be very frustrating not knowing the cause of the issue. However, I am glad to know the issue is resolved. As you mentioned you are using an legacy version of ActiveReports, it could possibly be a bug or just a different behavior with the rendering sequence.

    >> I can’t justify the upgrade cost, so that’s what I’m stuck with.

    As mentioned above ActiveReports 11 is a legacy product and no longer into maintenance which is why no bug fixes would be provided for the same. It is always a good idea to be updated with the latest tools and technologies. It’s been a long time since ActiveReports 11 and we have added many new features and provided fixes for previously reported bugs.

    One the big feature that we recently adding ActiveReports 16 is SectionReport support in Web Designer. As many of our customers use SectionReports and want to move to Web Technologies converting section reports to RDL Reports was a limiting factor but now we ActiveReports 16.2 you can design section reports in the web designer as well.

    We are currently planning to release ActiveReports 17 in few months so there are more surprises to come!

    If you want to know more on the newly released features please refer to the release notes:

    P.S. If you are considering to purchase ActiveReports but you are limited by the price point, I would suggest you to take your query to the sales team and they will be better to guide you with this. You can contact our sales team at or call 1.800.858.2739.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels