//create a memory table to store the totals
tblTotals := TMemoryTable.Create;
tblTotals.FieldDefs.Add('TTL_CLASS',ftInteger);
tblTotals.FieldDefs.Add('TTL_SUM',ftCurrency);
tblTotals.InMemory := True;
tblTotals.CreateTable;
//get the transaction totals per transaction classification
tblTransac.First;
while not(tblTransac.Eof) do
begin
if tblTotals.Locate('TTL_CLASS',tblTransac.FieldByName('TRN_CLASS').AsInteger,[]) then
begin
tblTotals.Edit;
tblTotals['TTL_SUM'] := TblTotals['TTL_SUM'] + tblTransac['TRN_VALUE'];
tblTotals.Post;
end;
tblTransac.Next;
end;
//use the total for transaction class 50 in some calcs
if tblTotals.Locate('TTL_CODE',50,[]) then
......
......
//use the total for transaction class 60 in some calcs
if tblTotals.Locate('TTL_CODE',60,[]) then
......
......
//free the table containing the totals
tblTotals.Active := False;
tblTotals.Free;