form and the new accumulated number of goals value outputted to the cumulative goals field..
I'm trying (!) to write a script so when the form is Submitted, the calculation occurs and the respective fields are updated.
Form Name is Goals1
Field Names are Team_Name,Opposition,Player_Name,Number_of_Goals,Cumulative_Goals
I'm trying to write script in Form.. On Add.. Validate.. currently trying to use a for each loop, but it appears this adds the accumulated value to the previous entry and leaves the more recent entry blank...
if ((input.Number_of_Goals > 0)
{
for each vgoal in Goals1 [(Player_Name == input.Player_Name && (Cumulative_Goals is null))]
{
x = Goals1 [(Player_Name == input.Player_Name && (Cumulative_Goals is null))];
x.Cumulative_Goals = x.Number_of_Goals;
}
for each vgoal in Goals1 [(Player_Name == input.Player_Name && Cumulative_Goals > 0)]
{
x = Goals1 [(Player_Name == input.Player_Name && Cumulative_Goals > 0)];
x.Cumulative_Goals = (x.Number_of_Goals + x.Cumulative_Goals);
}
}
Thanks for your time, any help or advice would be greatly appreciated..