Subform calculation

Subform calculation

Hi,

I have made a form with 4 subforms. I have added 4 fields that calculate the total for each subform (just adding numbers from each row). Used following code to do that:

t = 0.0;
for each spolu in Platby_CP
{
t = t + spolu.Suma;
}
input.Spolu_platby_CP = t;

Where Platby_CP is my subform and Suma is the value that I add. For each subform I only modify the name of the subform in line 2 and the field in last line.

I ran into the following problem - some subforms I get the right number. In some however, it looks like it is adding up all records in the subform report, ignoring what is in the subform field itself. I checked everything multiple times, but can't find any reason why this happens. I am new to Zoho, try my best to apply my previous experiences, but just can't crack this one