Totaling flowfield

clemboclembo Member Posts: 122
I've three table.

1. Vehicle
2 Header Assistance Vehicle
3 Rows Assistance Vehicle

When a vehicle go in assistance there is one record in the header assistance and one or more record in rows assistance.
In the Rows Assistance Vehicle there is a field Amount. In the Header Assistance Vehicle there is a flowfield Total (sum of all amount fields in row assistance vehicle when No. field in the header is same in rows assistance vehicle field "Document No."

Now I've built a form Vehicle Card.
In this form (Card Type form)I've a subform that shows all record of Header Assistance Vehicle related to Vehicle selected.
I want to show total amount(sum of all Total field in Header Assistance Vehicle) in the form but this is a flowfield so I cannot use sumindex.
In the subform I have created a function:

LocRec.COPYFILTERS(Rec);

WITH LocRec DO BEGIN
IF Rec.FIND('-') THEN REPEAT
CALCFIELDS("Totale Manutenzione");
Total := Total + "Totale Manutenzione";
UNTIL NEXT=0;
END;

EXIT(Total);

but my problem is that when i call this function from main form it use previous record filter not actual.
So every time I move to next record in main form i see totalof previous record!!

How I can solve this problem?

Comments

  • krikikriki Member, Moderator Posts: 9,110
    And from where do you call this function?
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • clemboclembo Member Posts: 122
    I call it from Vehicle Card.
    There is a textbox. Its SourceExpr is CurrForm.SubformManutenzioni.FORM.TotaleManutenzioni
  • BeliasBelias Member Posts: 2,998
    you did
    WITH LocRec DO BEGINIF Rec.FIND('-') THEN REPEAT
    CALCFIELDS("Totale Manutenzione");
    Total := Total + "Totale Manutenzione";
    UNTIL NEXT=0;
    END;

    EXIT(Total);
    this means that "totale manutenzione" refers to locrec, but i think you want to calculate it on rec, instead.
    moreover, you're doing the NEXT instruction on locrec, but again, i think you want to do it on rec, instead.

    edit: or most probably, you want to do it viceversa: in this way, simply remove "Rec." before the Find('-')
    ps: why did you use WITH for just a few lines? it's misleading...
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • krikikriki Member, Moderator Posts: 9,110
    In the function, pass the following parameter : the record of the table of the main form.

    In the function, use the info from that parameter to get your data.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • ssinglassingla Member Posts: 2,973
    Why can't you have a flowfield from row table instead of header table like customer card have "Balance" flowfield from table Detailed Cust. Ledger Entry and not from table Cust. Ledger Entry.
    CA Sandeep Singla
    http://ssdynamics.co.in
Sign In or Register to comment.