Summing up on the headerband

Briefly I want to show sum of a field that printed on previous pages.
And I drop a TfrxMemoView and set its expression property =
[SUM(<frxDBDataset1."AMOUNT">,MasterData1,2)]

but not calculating and showing. But same expression works on the pagefooter
band.

Where am I doing wrong?

Thanks for helps.

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 4:44PM
    see the main demo under scripts and dialogs see the grouptotal in header report.
    report must be 2 pass.
  • edited 4:44PM
    Thanks for interest.
    I saw the demo but I have no criter for groups. On the demo the sum is belong to current page I need to sum previous pages and show it current page's headerband. It is transferred sum from previous page.

    I can do it by summing on a variable and print it next pageheader but...
    previous pages sometime is not visible.
  • gordkgordk St.Catherines On. Canada.
    edited 4:44PM
    aggregate sums are designed to work with correct footers.

    create a variable at the start of the code page
    var mytot:extended;
    initialize to 0 in the empty begin end block of the codepage
    mytot := 0;
    in the obp event of masterdata or oad event of the memo containing the datafield
    mytot := mytot + <frxDBDataset1."AMOUNT">;
    in a memoview in header [mytot]
    if you dont want this memo to display when 0
    write code in the obpfor the memo
    memo1.visible := mytot> 0;

  • edited 4:44PM
    Thank you qordk.

    I did it the way that you told and it works properly but this is some complicated.
    And I plan that last users can change the design and customize the report so there must be less script.

    Let me tell about the main neccessity ;)

    There are a lot of transferred sum of amout, reminder or sht like that.

    The report query is contain data between '2005-01-01' and '2005-12-31' and I want to view the data after '2005-04-01' depending on the filter that user selected.

    the report will be like that on the pageheader of the first page contain sum of the amount as t1

    date < '2005-04-01'. and on the pageheader of the second page contain t1 + sum of first page and so on..

    The data with the date < '2005-04-01' eliminated by the disabling the visible of the bands.

    For this feature there are already a lot of scripts.

    My old report I was using Quick Report and I doing suming on the pageheader band. we give up using Quick report and for other useful properties we start to using Fast report. and I think this feature should be with fast report.

    Can Fastreport add this functionality in the near future?

    thanks.
  • gordkgordk St.Catherines On. Canada.
    edited 4:44PM
    Why go to all the trouble of hiding bands?
    just parameterize your query and select only what you want.
  • edited 4:44PM
    Why go to all the trouble of hiding bands?
    just parameterize your query and select only what you want.

    Becouse my filters system. End-User will chose the date filter as
    my example.. from '2005-04-01' to '2005-12-31'.

    I parameterize my query for this filter query will select date <= '2005-12-31'

    so I can get the sum of the records from begining but show the records after :firstdate ('2005-04-01').

    Other possibility.. I use an other query for summing transsfered sum before '2005-04-01'... But this is not optimum for me.

  • gordkgordk St.Catherines On. Canada.
    edited 4:44PM
    much simpler method would be to parameterize the query
    add a frxdialogpage with a dateedit control
    in the param editor of the query set the value prop to that of the dateedit.date.
    now you will retreive only the data required and you won't need to write code
    to hide unneeded data.
  • edited March 2006
    thank you qordk.
    But I think I couldn't tell my problem.

    My query is already parameterized and it comes from a different filter layaut
    so there is no need extra dialog boxes for asking date.
    There is no problem with parameterizing or not the query.

    My data is like that basicly

    CustId amount date


    Cust1 20 2005-01-01
    Cust2 50 2005-02-01
    Cust3 10 2005-03-01
    Cust4 40 2005-04-01
    Cust4 40 2005-04-25
    Cust4 40 2005-04-26
    Cust2 5 2005-05-01
    Cust6 20 2005-06-01
    Cust7 20 2005-07-01
    Cust1 20 2005-08-01
    Cust9 20 2005-09-01
    Cust10 20 2005-10-01
    Cust11 20 2005-11-01
    Cust12 20 2005-12-01
    Cust13 20 2005-12-08
    Cust14 20 2005-12-16

    and I want a report that filtered between '2005-04-01' and '2005-12-01'

    _______________________________
    page header of page1 transferred sum of amount 80
    _______________________________
    Cust4 40 2005-04-01
    Cust4 40 2005-04-25
    Cust4 40 2005-04-26
    Cust2 5 2005-05-01
    _______________________________
    page footer of page1 page total 125 transferred sum of amount 205
    _______________________________
    page header of page2 transferred sum of amount 205
    _______________________________
    Cust4 40 2005-04-25
    Cust4 40 2005-04-26
    Cust2 5 2005-05-01
    Cust6 20 2005-06-01
    _______________________________
    page footer of page1 page total 105 transferred sum of amount 310
    _______________________________
    page header of page3 transferred sum of amount 310
    _______________________________
    Cust7 20 2005-07-01
    Cust1 20 2005-08-01
    Cust9 20 2005-09-01
    Cust10 20 2005-10-01
    _______________________________
    page footer of page1 page total 100 transferred sum of amount 390
    _______________________________
    page header of page4 transferred sum of amount 390
    _______________________________
    Cust11 20 2005-11-01
    Cust12 20 2005-12-01
    Cust13 20 2005-12-08
    Cust14 20 2005-12-16
    _______________________________
    page footer of page1 page total 100 transferred sum of amount 490

    So how can I retrieve the data that I need?
    I have no chance use a database procedure and have to use just simple SQL.
  • gordkgordk St.Catherines On. Canada.
    edited 4:44PM
    The point of using the dialog was to keep it all within the report,
    you can do it where ever you want.
    I would use 2 queries
    a select sum query on the range below the given date to supply the begining value to the transfer varaiable.

    and a select query on the range = or above for the report
    no need to write filters, no need to hide bands

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.