icodefullstack
icodefullstack

Reputation: 1

Multiple "Page N of M" in a single VB6 ActiveReport

I have an active report which generates a report of multiple pages. I need it to show page N of M multiple times based on a field "COID" present in Details section. For Eg- if there are 10 pages(2 for COID 1001, 1 for COID 1002 and 7 for COID 1003) So, I want the pages like "Pages 1 of 2", "Pages 2 of 2", "Pages 1 of 1", "Pages 1 of 7", "Pages 2 of 7".... "Pages 7 of 7".

Please help.

Upvotes: 0

Views: 1853

Answers (2)

Tony Shih
Tony Shih

Reputation: 436

I have worked only with AR version 3.00 on wards. In these it could be achieved very quickly and easily using a sub report.

I did a quick research on this and found earlier version supports sub reports

How to do this using a sub report follow the article in the link and create a parent and child/sub reports. For parent report data you just run a SQL query group by COID and pass each COID to the sub report. I would have envisage an almost blank parent report with a detail section in that detail section insert a sub report control. Assign your existing report to the sub report control.

Sub report has their own issues as long as we keep the parent and sub report communication simple. And also create only one sub report instance object in the parent report. Use the same instance to pass the parameter from each row in the parent dataset which is COID.

Upvotes: 1

Scott Willeke
Scott Willeke

Reputation: 9335

There are two ways to do this. Run a single report and reset the page numbering on each group and running the report multiple times and merging pages together into one report.

Resetting Page Number for Each Group

See this topic in the ActiveReports for ActiveX/COM documentation. It is merely a matter of setting the right properties on the textbox control.

Merging Reports Together

In this method you can run the report separately for each COID group (e.g. using a WHERE clause to get the right data). This will get the page numbers the way you want in each COID report. Then you can merge the pages from each of tho together into a single report. So something like the following:

For iRpt = 0 to myReports.Count - 1
    rpt = myReports[iRpt]
    For iPage = 0 to rpt.Pages.Count – 1
        mainReport.Pages.Insert(rpt.Pages(iPage))
    Next iPage
Next iRpt

Find more information on the Pages collection here.

Upvotes: 0

Related Questions