I've tried finding a solution to this on my own using other examples from previous forum posts, but nothing has worked. I have a form containing some fields that perform a simple "present value" calculation. The calculation works, but when you open the form, I receive the following error:
Of course, all of the fields involved in the calculation are blank when the form opens, so there's nothing to calculate, which is, I think, what is causing this error.
Is there some formcalc script I can use to prevent this error?
This produced the right result, but I still received the error message when tabbing out of InterestRate.
As a workaround, I can swap the fields so that PaymentsPerPeriod appears first, which would work fine unless someone manually filled in the InterestRate field first without using the tab function. I just wish I could get a script to work.
The calculation for the PresentValue field is PV (PaymentAmount.rawValue, InterestRate.rawValue / PaymentsPerPeriod.rawValue, TotalPayments.rawValue). All of these fields have to have a value (user-entered) to calculate the PresentValue field. The calculation works just fine, it's just that when you place a value in InterestRate, before placing a value in PaymentsPerPeriod (by which InterestRate is divided), you get the error. So, I need to be able to tell it to only calculate when InterestRate is not zero, but I can't find the right script to make it work.
Typically this means there's something in your calculation that causing the overflow and may happen until you (or the user) enter data that doesn't cause an overflow. Is the calc dependent on two or more separate values that must be present in order to get a valid result?
Depending on what the calculation takes place (i.e. on Exit event) you might be able to modify the script to something like:
if ( $ > 0) //only perform calc if entered value is gretare than zero