running total ?

well, i want to make a invoice form using master detail relation but i got problem to show total ammount of detail item. Help me please.
delphystAsked:
Who is Participating?
 
ZifNabConnect With a Mentor Commented:
Use SQL,

something like this :

SELECT SUM(O.ItemsTotal), SUM(O.AmountPaid)
FROM ORDERS O

Regards, Zif.

0
 
delphystAuthor Commented:
i'm using
-TTable both for master and detail

0
 
ZifNabCommented:
delphyst,

use a query for it or make your detail also a master of another detail (=> this one calculates total of detail).

Zif.
0
 
vladikaCommented:
See example in Delphi 3\Demos\DB\CtrlGrid\CtrlGrid.dpr
procedure TDM1.CalculateTotals(Sender: TObject; Field: TField);

In short
    Detail.disableControls;  { hide this process from the user }
    Detail.first;
    while not Detail.eof do
    begin
      // calculate Totals
      Detail.next;
    end;
    Detail.first;
    Detail.enableControls;  { restore the display }

If you want only total ammount of detail item
use Detail.RecordCount

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.