PageEnd event fires twice for the same page?

Posted by: gbetsos on 4 August 2017, 2:56 pm EST

  • Posted 4 August 2017, 2:56 pm EST

    <FONT face=Verdana>I am relatively new to AR2 and trying to understand how its event mechanism

    <FONT face=Verdana>In my report I have placed a text control, <FONT face="Times New Roman"><FONT face=Verdana>lblPageno</FONT>,</FONT> on the page footer with</FONT>

    <FONT face=Verdana>SummaryFunc = ddSFCount and
    SummaryType = ddSMPageCount,</FONT>

    <FONT face=Verdana>i.e. the control is set each time with the current page number.</FONT>

    <FONT face=Verdana>Inside ActiveReport_PageEnd() I have placed the following line of code</FONT>

    <FONT face=Verdana>MsgBox lblPageno.DataValue</FONT>

    <FONT face=Verdana>After executing the report I get:</FONT>

    <FONT face=Verdana>1
    </FONT><FONT face=Verdana>2
    </FONT><FONT face=Verdana>3
    </FONT><FONT face=Verdana>4
    </FONT><FONT face=Verdana>5
    </FONT><FONT face=Verdana>5
    </FONT><FONT face=Verdana>6
    </FONT><FONT face=Verdana>7
    </FONT><FONT face=Verdana>8
    </FONT><FONT face=Verdana>9
    </FONT><FONT face=Verdana>10
    </FONT><FONT face=Verdana>11
    </FONT><FONT face=Verdana>11</FONT>

    <FONT face=Verdana>My reports consists of only 10 (not 11) pages.</FONT>

    <FONT face=Verdana>I don't understand why the PageEnd event fires twice for page no. 5. Also,
    how is it possible that the event keeps on firing, even after the last page
    of the report (i.e. page number 10) has been reached.</FONT>

    <FONT face=Verdana></FONT> 

    <FONT face=Verdana></FONT> 

  • Replied 4 August 2017, 2:56 pm EST

    The events and events sequence is explained in the following kb articles:
    <span class="txt2"><b>
    INFO: Understanding ActiveReports' Events and Event Order Sequence</b></span>

    <span class="txt2"><b>
    INFO: Detail Section in Depth</b></span>

    I think there is something missing in the information you provide as the lblPageno as specified doesn't produce the page numbers you list. Because you set the SummaryType to ddSMPageCount, you should get the number of pages on all the pages (10). Do you have the DataField set to some field? can you compress and post this report and we'll have a look.
  • Replied 4 August 2017, 2:56 pm EST

    <FONT color=#000000><FONT face=Verdana>lblPageno's properties are exactly as I described. I just omitted to quote that I have 
    also set SummaryRunning  to  2-ddSRAll. </FONT><FONT face=Verdana>This gives the current page number.</FONT></FONT>

    <FONT face=Verdana color=#000000></FONT>

    <FONT face=Verdana color=#000000>Anyway, I found out why PageEnd event was firing twice for the same page. The first
    time it was firing for a page that wasn't actually rendered at all!</FONT>

    <FONT color=#000000><FONT face=Verdana>In my report I have two groups, say group1 and group2. The group order is
    group1 -> </FONT><FONT face=Verdana>group2.</FONT></FONT>

    <FONT color=#000000><FONT face=Verdana>The group footer of group1 </FONT><FONT face=Verdana>has </FONT></FONT><FONT face=Verdana color=#000000>NewPage set to ddNPAfter whereas group footer of
    group2 has NewPage set to ddNPBeforeAfter. </FONT><FONT face=Verdana color=#000000>What I want to print is salaries of
    persons grouped BY group1, group2.</FONT>

    <FONT face=Verdana color=#000000>Here is an example of a list of values I have in my data set:</FONT>

    <FONT face=Verdana color=#000000>ID  Name   group1 group2 Salary</FONT>

    <FONT face=Verdana color=#000000>1   Smith       A        X        1200$</FONT>

    <FONT face=Verdana color=#000000>2   Brown       A        X        1100$</FONT>

    <FONT face=Verdana color=#000000>3   Peterson   A        Y        1300$</FONT>

    <FONT face=Verdana color=#000000>4   Floyd        A        Y        1200$</FONT>

    <FONT face=Verdana color=#000000>5   Carrot       A        Y        1000$</FONT>

    <FONT face=Verdana color=#000000>6   Parrot       B        X        1200$</FONT>

    <FONT face=Verdana color=#000000>.... etc</FONT>

    <FONT face=Verdana color=#000000>Persons with IDs 1,2 are printed on page no 1, persons with IDs 3, 4 and 5
    on page no 3. 
    </FONT><FONT face=Verdana color=#000000> Pages no 2 and 4 contain a summary report with subtotals (remember that group2 has NewPage set to ddNPBeforeAfter). </FONT>

    <FONT face=Verdana><FONT color=#000000>Now rendering of page number 5 begins (due to <FONT face=Verdana>NewPage = ddNPAfter of group1
    I guess), but nothing is rendered, not even a blank page. After record with ID = 6
    is reader PageStart fires once more and this time the details that follow are rendered
    on it.</FONT></FONT></FONT>

    <FONT face=Verdana color=#000000></FONT> 

    <FONT color=#000000></FONT> 

    <FONT color=#000000></FONT> 

    <FONT face=Verdana color=#000000></FONT> 

    <FONT face=Verdana color=#000000></FONT> 

    <FONT face=Verdana color=#000000></FONT> 

    <FONT face=Verdana color=#000000></FONT> 

    <FONT face=Verdana color=#000000></FONT> 

    <FONT face=Verdana color=#000000></FONT> 

    <FONT face=Verdana color=#000000></FONT> 

Need extra support?

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

Learn More

Forum Channels