I'm trying to creating a form where there will be 3 fields. two numeric fields and a third numeric field where I'd like to show the total percentage ex: field A 70 / field B 100 *100 = Field C (Total Percentage) but I keep getting a arithmetic underflow error. Need some help
I thought it would be something like:
Field C=FieldA/FieldB*100
but I keep getting the arithmetic underflow error. The formula actually works but I'm trying to get rid of that error.
Please help if possible. Thanks.
Solved! Go to Solution.
Views
Replies
Total Likes
I did not set any default values to Field1 and Field2 - they are just user entered fields and will appear blank on your form. In order to avoid dividing by zero, you have to first determine if there are values in Field1 and Field2. In my example, if either Field1 or Field2 is blank, I set the value of Field3 to 0 (using an "If, elseif, then" statement). Only when there are 2 values will the division operation occur.
The code is formcalc, entered in the calculate event of Field3.
if (HasValue(Field1) eq 0) then
Field3 = 0
elseif (HasValue(Field2) eq 0) then
Field3 = 0
else
Field3 = Field1 / Field2
endif
An example is found here: Dropbox - Avoid Division by Zer0.pdf
Have you set default values (of zero) for your numeric fields?
Views
Replies
Total Likes
The fields are set to default zero. The fields are set where the users have the option to fill in a numeric value. If no value has been inputted, then the value is zero
Thanks geegee for replying
Views
Replies
Total Likes
You actually just answered your own question. When the form is rendered, because the default of the second field is zero, you are attempting to divide by zero - which is generating the error.
What you need to do is set up a If .... Then statement in the calculate event of Field3. If the fields are zero, put zero in Field 3. If the two fields have values, then perform Field1 / Field 2.
Views
Replies
Total Likes
hi latenite..thanks for responding.I am not familiar with writing an ( if..then statement.) I know where I need to write it but what would the if statement look like if possible?
Views
Replies
Total Likes
I did not set any default values to Field1 and Field2 - they are just user entered fields and will appear blank on your form. In order to avoid dividing by zero, you have to first determine if there are values in Field1 and Field2. In my example, if either Field1 or Field2 is blank, I set the value of Field3 to 0 (using an "If, elseif, then" statement). Only when there are 2 values will the division operation occur.
The code is formcalc, entered in the calculate event of Field3.
if (HasValue(Field1) eq 0) then
Field3 = 0
elseif (HasValue(Field2) eq 0) then
Field3 = 0
else
Field3 = Field1 / Field2
endif
An example is found here: Dropbox - Avoid Division by Zer0.pdf
Hi lateniteNC, thanks again for all the help. I imputed the formcalc code in and this is what im getting:
I replaced the Field 1, 2, 3 with the names appropriate to the names on the worksheet.
Again thanks for all the help. I am super super noob when it comes to this..
Views
Replies
Total Likes
Hi lateniteNC, thanks again for all the help. I imputed the formcalc code in and this is what im getting:
I replaced the Field 1, 2, 3 with the names appropriate to the names on the worksheet.
Again thanks for all the help. I am super super noob when it comes to this..
Views
Replies
Total Likes
If you can upload your form I will take a look. Looks like you make have a reference name issue but cannot tell until I can view the form.
Views
Replies
Total Likes
hey lateniteNC, I can't seem to figure out how to upload my form into the forum. Have any recommendations on how I can do that?
Views
Replies
Total Likes
Thank you so much lateniteNC. I was stumped on why the formula wouldn't work and I did a little more digging and I found a script that was written in the ALL EVENT script editor that was giving me the error codes. I removed the script and everything is working perfectly.
Thanks again.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies