script calcing problem

ibrahim bulutibrahim bulut turkey
edited 12:57AM in FastReport 4.0
hi folks,
i am trying to calculate(sum) a field value within a script but i can not success.

my code is that

procedure ReportSummary1Onbeforeprint(Sender : TfrxComponent);
Var Total : Double;
begin
Total:=Sum(<frxdbdataset1."field1">);
// result is always null, but fields has values.
// memo component which uses the same expression no problem i can see the total.
// also i tried report.calc metod but no success. what i must do
end;

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 12:57AM
    read the manuals
    select your memoview rtclick edit use the aggregate expression builder.
  • ibrahim bulutibrahim bulut turkey
    edited 12:57AM
    gordk wrote: »
    read the manuals
    select your memoview rtclick edit use the aggregate expression builder.

    i don't want to do it in a memoview. it's in the script.
    and my expression is working good in a memoview.

    i want to do it in a summary band before print event.
    also i tried the sum function with band parameter
    Total:=Sum(<frxdbdataset1."field1">,Masterdata1) and // always null
    Total:=Sum(<frxdbdataset1."field1">,Masterdata1,1) // always null

    i tried with report.calc function but result is null

    i think, there is a limitations with aggregate functions in the script.
  • gordkgordk St.Catherines On. Canada.
    edited 12:57AM
    you can't do it that way the dataset is already closed that is why the null.
    if you would read the manuals you would Know about the limitations.
    if you want to use script declare your variable in the correct place and use the crooect obp of the correct band.
    var
    Total: double;// global available to all events in the report at top of code page
    obp of masterdata
    Total := Total + <datasetname."fieldname">;
    begin
    Total := 0; // initialize in the default block or in onstart treport event
    end.
  • ibrahim bulutibrahim bulut turkey
    edited 12:57AM
    no gord, dataset is not closed it is open.
    i have read the manuels and i can not see any limitations about this.
    please write me where is the limitations

    gordk wrote: »
    you can't do it that way the dataset is already closed that is why the null.
    if you would read the manuals you would Know about the limitations.
    if you want to use script declare your variable in the correct place and use the crooect obp of the correct band.
    var
    Total: double;// global available to all events in the report at top of code page
    obp of masterdata
    Total := Total + <datasetname."fieldname">;
    begin
    Total := 0; // initialize in the default block or in onstart treport event
    end.
  • ibrahim bulutibrahim bulut turkey
    edited 12:57AM
    i can read field's value in reportsummaryband beforeprint event so, dataset is not closed.
    i thinks the problem is about aggregate function.
    i can do it now with fastreport 2,5.
    i can get total with TOTAL:=[SUM(QUERY1."FIELD1")];

    no gord, dataset is not closed it is open.
    i have read the manuels and i can not see any limitations about this.
    please write me where is the limitations

    you can't do it that way the dataset is already closed that is why the null.
    if you would read the manuals you would Know about the limitations.
    if you want to use script declare your variable in the correct place and use the crooect obp of the correct band.
    var
    Total: double;// global available to all events in the report at top of code page
    obp of masterdata
    Total := Total + <datasetname."fieldname">;
    begin
    Total := 0; // initialize in the default block or in onstart treport event
    end.
  • gordkgordk St.Catherines On. Canada.
    edited 12:57AM
    users manual Script
    "Using aggregate functions in the script"
  • ibrahim bulutibrahim bulut turkey
    edited 12:57AM
    thanks gord,
    i will check it
    gordk wrote: »
    users manual Script
    "Using aggregate functions in the script"

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.