Expand my Community achievements bar.

SOLVED

New to LiveCycle and was dumped a project to complete.

Avatar

Level 1

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.

1 Accepted Solution

Avatar

Correct answer by
Level 4

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

View solution in original post

10 Replies

Avatar

Level 2

Have you set default values (of zero) for your numeric fields?

Avatar

Level 1

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

Avatar

Level 4

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.

Avatar

Level 1

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?

Avatar

Correct answer by
Level 4

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

Avatar

Level 1

Hi lateniteNC,  thanks again for all the help.  I imputed the formcalc code in and this is what im getting:

1102309_pastedImage_0.png

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..

Avatar

Level 1

Hi lateniteNC,  thanks again for all the help.  I imputed the formcalc code in and this is what im getting:

1102335_pastedImage_0.png

1102334_pastedImage_0.png

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..

Avatar

Level 4

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.

Avatar

Level 1

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?

Avatar

Level 1

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.