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

How can you remove the zero from calculation field, if there is no value

New Here ,
Oct 14, 2016 Oct 14, 2016

Adobe Acrobat XI Pro -- Fillable Form

Hi,

I have a successful calculation using the simplified field notation (on the calculation tab) in my field called VacationBalance2.

(VacationBalance1 + HoursAccrued2) - HoursTaken2

How can I say, if there is no value in HoursTaken2, put nothing in VacationBalance2?  As in, do not show a zero.

I have tried semblances of:

IF(HoursTaken2 = "","",(VacationBalance1 + HoursAccrued2) - HoursTaken2)

I have tried it like this, putting an equal sign in front of the IF, the way I would do it in Excel:

=IF(HoursTaken2="","",(VacationBalance1 + HoursAccrued2) - HoursTaken2)

I have tried saying:  If(HoursTaken2=0,"", etc.

or:  If(HoursTaken2 Is "", "",  etc.

In the above case, I have been able to not show the zero, but then I also do not get an answer if HoursTaken2 DOES have a value in it.  See below.

Again, my original formula works, but it shows a zero.  How do I make it NOT show a zero, if there is nothing in the "Hours Taken" field?  But, if there IS a value in Hours Taken, then I DO need the formula to work.

I'd appreciate any help.

Thank you.   : )

TOPICS
Acrobat SDK and JavaScript
2.2K
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 ,
Oct 14, 2016 Oct 14, 2016

At the end of the calculation code add this line:

if (event.value==0) event.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 12, 2016 Dec 12, 2016

Hi try67,

Thanks for your help.  I didn't have much time to reply back earlier, as October & November were crazy busy months for me.

I may not have originally shown a perfect example of what my problem was.  After I added some data, the problem seemed a little different.

Here is a better example of what happens when I use my original calculations for line items 1 - 4:

(BegVLBal + VLHoursAcc1) - HoursTaken1

(VacBal1 + VLHoursAcc2) - HoursTaken2

(VacBal2 + VLHoursAcc3) - HoursTaken3

(VacBal3 + VLHoursAcc4) - HoursTaken4

Line items 3 & 4 take on the balance of line item 2.  I would like them to show nothing, unless there is something in the Hours Taken field for their respective rows.

Then when I added your addition to the end of my code (on line item 2, only) ...

(BegVLBal + VLHoursAcc1) - HoursTaken1

(VacBal1 + VLHoursAcc2)-HoursTaken2; if(HoursTaken2.value==0)VacBal2.value="";

(VacBal2 + VLHoursAcc3) - HoursTaken3

(VacBal3 + VLHoursAcc4) - HoursTaken4

I get a zero, but line item 2 should actually have a balance of 1,998.00

Did I apply your "event.value" incorrectly?  I first tried it this way:

(VacBal1 + VLHoursAcc2)-HoursTaken2; if(event.value==0)event.value="";

But then thought that maybe I was supposed to put my actual field name instead of "event."  Sorry I am not knowledgeable enough for this.

: (     I also tried replacing event.value completely with just the field name.  I also tried putting your code at the beginning of the calculation instead of at the back.

: (

Also, keep in mind, this code is in the "simplified field notation" area on the calculation tab.  It is not in the "custom calculation script" area.

Can you help figure out how I can get a zero in the "Vacation Balance" field if there is no value in the "Hours Taken" field?

Thank you so much.

Sincerely,

somebunny

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 12, 2016 Dec 12, 2016

oops ...  I said that wrong at the end. 

I don't want a zero in the "Vacation Balance" field if there is nothing in the "Hours Taken" field.  I want nothing to show up in the "Vacation Balance" field if there is nothing in the "Hours Taken" field.

But if there is a value in the "Hours Taken" field, I need the "Vacation Balance" field to show the value.

Thanks.   : )

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 16, 2016 Dec 16, 2016
LATEST

Hi Try,

That's okay; never mind about this problem.  I am just going to let the previous balance show up on all lines, until they are used.  I'm exhausted of trying to make it show "nothing" in the balance field, when the row hasn't been used yet.

Using the following JS code in simplified field notation:

     (Previous Balance + Hours Accrued) - Hours Used

Thank you for trying.  I will probably ask you some other questions I have coming up.

Regards.

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