* Get the Bill Details. .oFile.open('Billdet') select SourceCode + CapCode, Ky ; from Billdet ; where KyBill = m.lnKyBill ; order by 1 ; into array laResults *** As you see here I can get the amount by simple select and the amount is correct * SELECT sum(Amount) as TotalAmount FROM BillDet WHERE kyBill = m.lnKyBill .DetailCount = _tally if .DetailCount = 0 dimension .Details[1] .Details[1] = .null. else dimension .Details[.DetailCount] for i = 1 to .DetailCount .Details[m.i] = newobject('CBillDet', 'c_billdet.prg') .Details[m.i].GetRec(laResults[m.i, 2]) if .Details[m.i].InterestCount > 0 .hasInterestAttachment = .t. endif * Changed by Nadya Nosonovsky at 08/08/2007 05:30:00 PM * Here I'm trying to follow the flow and use this complex reference, but I end up with the wrong number .nTotalAmount = .nTotalAmount + .Details[m.i].oTabBillDet.oFields.Amount && Let's calculate total amount endfor endif use in 'Billdet'Trying to follow the logic and see all this complex classes seems to be impossible.