Problem calculating currency value

Problem calculating currency value

Hi all,
I know it is a quite stupid question but I can't find any solution even if I tried everything!

I have a form which represents an order. This has some records stored in another form. Each of these records has a quantity (decimal) field and a cost (currency type). I need to update the total of the order.

...
total = 0.00;
for each p in products
{
      total = total + (p.cost * p.totalQty);
      ...
}
...
order = frmOrder [ID == orderID];
order.total = total;

Instead having the cost multiplied by the quantity I have only the cost sum. What should I do? Thank you very much!