probleme with SUM

edited December 2012 in FastReport 4.0
hello,

I build a report and it was OK.
The only problem is that the footer was not all the time at the bottom of the page, depending on the row number of the detaildata band.

So I decided to add a child band with some vertical line on it, and I added this code on the footer obp event:
procedure Footer1OnBeforePrint(Sender: TfrxComponent);
begin
while engine.freespace > (child1.height + footer1.height) do
begin
engine.showband(child1);
end;    
end;

Now it seems to be OK concerning the position of the footer band, but a new problem occured: the sum on the footer band doesn't appear any more.
It seems that the child band printed between the detaildataband and the footer gives some trouble to the SUM

The sum code is : [SUM(<frxDBDataset2."LAPUMONTANT">,DetailData1)]

Regards

Comments

  • gpigpi
    edited 5:42PM
    attach your report template (fr3) and saved preview pages (fp3) here
  • edited December 2012
    hello,

    Here are the files.
    For security reasons, i have removed information on header and footer

    regards
  • edited 5:42PM
    hello,

    I have found somebody who has the same trouble.

    http://www.fast-report.com/en/forum/index....#092;.freespace

    I did the same written in that post and it's working.
    But it's very strange to put the reset of the variable on the Footer1OnAfterPrint event ?
    For me it was more logical to put that code on the OnStartReport event, but it doesn't work, the variable result is multiplicated by 2 !!

    Do someboby can explain that ?

    Here is my code
    procedure Footer1OnBeforePrint(Sender: TfrxComponent);
    begin
    while engine.freespace > (child1.height + footer1.height) do
    begin
    engine.showband(child1);
    end;    
    end;
    
    procedure DetailData1OnBeforePrint(Sender: TfrxComponent);
    begin
    Set( 'ReportTotal', get('ReportTotal') + <frxDBDataset2."LAPUMONTANT">);
    end;
    
    procedure frxReport1OnStartReport(Sender: TfrxComponent);
    begin
    //Set( 'ReportTotal',0);     // not working   
    end;
    
    procedure Footer1OnAfterPrint(Sender: TfrxComponent);
    begin
    Set( 'ReportTotal',0);    //ok
    end;
    
    begin
    
    end.
    

    regards
  • edited 5:42PM
    hello,

    Yes the code works good.

    But i'm just wondering why the code to reset the variable on the procedure OnStartReport doesn't work ?
    It's strange for me to reset the variable at the end of the report ?

    Regard
  • edited 5:42PM
    fred42 wrote: »
    But i'm just wondering why the code to reset the variable on the procedure OnStartReport doesn't work ?
    It's strange for me to reset the variable at the end of the report ?
    This is not an answer to your question but an alternative.
    I set report totals in the OnBeforePrint event of a ReportTitle band. I don't use ReportTitle for anything else so I also set its height to 1 at run time.
  • gpigpi
    edited 5:42PM
    Also try to set totals in the OnBeforePrint event of a TfrxReportPage
  • edited 5:42PM
    hello,

    I come back with this old post because I found a new problem.

    The following code works good if engine.freespace > (child1.height + footer1.height)
    But if the engine.freespace is lower than (child1.height + footer1.height) the footer is printed at the top of the following page [img]style_emoticons/<#EMO_DIR#>/mad.gif" style="vertical-align:middle" emoid=":angry:" border="0" alt="mad.gif" /> I think I need to write some code in the ?????? section (see below). I tried different possibilities but no result. What I want is to have the footer always at the same position: at the bottom of the page. The free space between detaildata and footer must be filled with empty line (child1). Or the page must be filled from the top to the bottom if the footer is printed on the following page.[/img]
    procedure Footer1OnBeforePrint(Sender: TfrxComponent);
    begin
    if engine.freespace > (child1.height + footer1.height) then
    begin
    while engine.freespace > (child1.height + footer1.height) do
    begin
    engine.showband(child1);
    end;
    end
    else
    begin
    ???????????
    nd;
    end;
    
    procedure DetailData1OnBeforePrint(Sender: TfrxComponent);
    begin
    Set( 'ReportTotal', get('ReportTotal') + <frxDBDataset2."LAPUMONTANT">);  
    end;
    
    procedure Page1OnBeforePrint(Sender: TfrxComponent);
    begin
    Set( 'ReportTotal',0);  
    end;
    
    begin
        
    end.
    

    Thank you
  • edited April 2013
    fred42 wrote: »
    But i'm just wondering why the code to reset the variable on the procedure OnStartReport doesn't work ?
    It's strange for me to reset the variable at the end of the report ?
    I had some problems in the past and I concluded that the event naming of the report component is not very illustrative as to its function.
    I may be wrong here but it may give you an idea why you have above problem,
    OnStartReport refers to the start of building the report structure and not the start of content generation.
    If you have a 2-pass report then the variable is initialized but not where you expect it, before content generation, resulting in doubled up values.

    The question I have is: why not manage the positioning of the footer band in the same way the position of the ReportSummary band is managed, using CurY := <expression>? There are numerous examples in this forum of how that is done.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.