On a form used in our hospitals for pre-admitting patients I'm trying to calculate BMI from height and weight. I've put the formula in the script editor and it correctly calculates BMI, but when the form is first opened the following error message appears:
Script failed (language is formcalc; context is xfa.form.F.#subform.BMI) script=(Weight*703)/Height*Height)
Error: arithmetic over/underflow.
I suspect this is because the denominator (Height*Height) is zero before a value has been entered into Height. Is this correct, and regardless whether it is or not, how can I avoid this error message? The users are nurses and they tend to unwind when they encounter technical error messages.
Found the answer myself. It was a problem with a zero denominator. By using an if/then/endif you can control when it's trying to run the calculation.
The original formula was (weight*703)/(height*height).
The solution was:
That prevents it from trying to run the calculation before a value has been entered in 'height'.