Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Form fields going negative then positive...

New Here ,
Dec 11, 2017 Dec 11, 2017

Hello,

I have been tinkering around with a form for my VFW, it is an expense report essentially.  The problem I am having is that the mileage is being calculated as first negative, due to the departure reading being entered first, and then changing to positive once the arrival reading is entered.  However, the calculation of the PER DIEM (@ $0.50/mile) stays negative? ... even after the mileage changes to positive, why?

Elaborated:

  • Entering something in the METERDEP cell, ex. 1, puts a -1 in the MILEAGE cell... but the calculation is supposed to be waiting for the METERARR reading.
  • The PERDIEM_DEP cell stays $0.00.
  • Entering something in the METERARR cell, ex 2, changes the MILEAGE cell to 1 and now the PERDIEM_DEP cell reads -$0.50.  How and why?
  • Moving on to METEREDEP_2 and entering 1, changes the PERDIEM_DEP to $0.50 now?!?!? 

I am confused... it's like Acrobat is acting very buggy.

TOPICS
PDF forms
1.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Dec 11, 2017 Dec 11, 2017

That's NOT the calculation order, which I'm betting is where your problems come from.

You need to check it in Form Edit mode, under Other Tasks (or More, depending on your version).

The order the fields appear in that list is the order they are calculated in. If that order is incorrect you will get the wrong results each time.

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 11, 2017 Dec 11, 2017

If a field has a value of a null string JavaScript treats the null like zero, 0, so if your ending mileage is zero and you are subtracting your non-null beginning mileage from zero I would expect a negative value. You can test the ending mileage for being either zero nor a non-zero value and then perform the calculation.

You will have to write a custom JavaScript calculation and use the "if...then" statement to control the calculation. You may also need to specify the field calculation order and check the JavaScript console in Acrobat for any errors.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 11, 2017 Dec 11, 2017

Thank you... I did expect to see the negative until something was entered in the METERARR field, but it confused me that Acrobat updated the ODOMETER field to a positive yet calculated a negative $ amount???

It was even more confusing to see the $ amount change to positive when I clicked in the METERDEP2 field... prior to even entering anything?!?

I used the Simplified Field Notation section to put the METERARR first in the equation ===> METERARR - METERDEP, but it still calculates it without the METERARR value?!?

I haven't played with "if... then" statements so worried I would mess it up even more if I tried!

Thanks again.

EDIT - It also fails to update the fields if I go back and change a value... that is until I change another value but it is only for the first one?!?!  Meaning the first departure/arrival meter reading.  If I go and modify another departure reading on line 2 or even 3, they immediately update?!?!  All of the calculations are identical for each successive line item.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 11, 2017 Dec 11, 2017

Did you check the calculation order?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 11, 2017 Dec 11, 2017

Yes... they all have the arrival value before the departure value.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 11, 2017 Dec 11, 2017

Screen Shot 2017-12-11 at 1.24.03 PM.png

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 11, 2017 Dec 11, 2017

That's NOT the calculation order, which I'm betting is where your problems come from.

You need to check it in Form Edit mode, under Other Tasks (or More, depending on your version).

The order the fields appear in that list is the order they are calculated in. If that order is incorrect you will get the wrong results each time.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 11, 2017 Dec 11, 2017
LATEST

SHEESH! 

Thank you... I was looking for how to arrange the calculations and never looked there... shuffled them around and VIOLA!

Thanks again.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines