By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,998 Members | 2,815 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,998 IT Pros & Developers. It's quick & easy.

Incrementing a Counter in a Subreport - Initializes on Next Page

P: 44

I use a counter in a subreport. The subreport is the primary data presentation for the report, and it covers more than 1 page.

I use the OnFormat event of the Detail section to conditionally initialize the counter.
I use the Onprint event of the Detail to increment the counter.

The problem is, that the counter seems to initialize itself when the report is pushed to a new page. The response is different if I have the "Keep Together" property set to "Yes" versus set to "No".

Ideally, I want this increment logic in OnFormat and OnPrint to behave the same from one page of the report to the next.

Can anybody help me?

Jun 3 '08 #1
Share this Question
Share on Google+
2 Replies

Expert Mod 2.5K+
P: 2,545
If a section spills over more than one page that section's Format event is bound to occur more than once, as a separate event for each page (possibly also involving the use of the Retreat event as it goes from one page to the next) After all, the first page is formatted before it is printed, and if a section spills onto the next page the report generator must start again in formatting the new page with any header etc before formatting the spillover section.

In setting up just one page the format event may potentially occur several times, which is why there is a FormatCount value passed to the Format event handler.

It seems to me that using On Format of the detail section to initialise your counter is not going to help you, because by its nature it can occur more than once for the same subreport.

What can help you is the use of a group header placed immediately before your subreport, even if this group header comprises just a single line as a separator. You can use the On Print event of the header to initialise your variable, as the header will not recur until after you have printed your subreport, even if the subreport spills onto another page.

Jun 3 '08 #2

P: 44
Thanks Stewart!

I've changed my approach to exclusively use the "On Print" event in the sub-report. Currently, I've found no condition where that doesn't work on my reporting.

Your response was very helpful. Thanks!

Jun 4 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.