My form contains a subform (row) with 5 radio buttons, with values (scores) of 5,4,3,2, and 1. The user may add another of these subforms by clicking a button.
My intention is to set a field with the average score -- that is, obviously, the total scores, divided by the number of rows. Here is my FormCalc for the calculate event of the Average field -- complete with error message:
b Script failed (language is formcalc; context is
b xfa[0].form[0].form1[0].Pg1[0].#subform[2].EssentialAv[0])
b script=
b var totPts =
b Sum(form1.Pg1.EssentialJobRow[*].RadioButtonList.#field[3])+
b Sum(form1.Pg1.EssentialJobRow[*].RadioButtonList.#field[2])+
b Sum(form1.Pg1.EssentialJobRow[*].RadioButtonList.#field[1])+
b Sum(form1.Pg1.EssentialJobRow[*].RadioButtonList.#field[0])+
b Sum(form1.Pg1.EssentialJobRow[*].RadioButtonList.#field[4])
b var numRows =
b Count(form1.Pg1.EssentialJobRow[*].RadioButtonList.#field[4])
b //$.rawValue=totPts
b //$.rawValue=numRows
b $.rawValue = totPts/numRows
b Error: arithmetic over/underflow.
I have used the commented lines in debugging, to prove that the total score and the number of rows are being calculated correctly. There is always at least one instance of the subform, so numRows is always greater or equal to 1 -- never 0.
This is such a simple thing, I know the answer must be staring me in the face, but I do not see it.
Thanks for any suggestions you may have.