5 Replies Latest reply on Nov 13, 2014 3:09 PM by Hik5ta

    Value Entered Does Not Match the Format of the Field

    Hik5ta Level 1

      Hi all,

       

      I would love some assistance with an error message I'm receiving.

       

      I am trying to create a form to assign a target ($) to each staff member working on a particular day based on individual hours worked, there could be between 1 and 6 people working so I can sometimes have an empty value which is where I believe I am having trouble.

       

      I would like to keep the field formatted to number ($) with no decimal places

       

       

      I have the following fields:

       

      Total budget for day: (BudgetMon)

       

      Hours worked by each staff member on the day, could be up to 6 staff in total: (hours1mon), (hours2mon), (hours3mon), (hours4mon), (hours5mon), (hours6mon)

       

      Staff members individual budget for day: (target1mon)

       

       

      Equation wise I need:

       

      (BudgetMon / ( hours1mon + hours2mon + hours3mon + hours4mon + hours5mon + hours6mon)) * hours1mon

       

       

      I am using the simplified field calculation field and whilst I am getting the correct answer/information it is also producing many error messages.

       

      Any help would be greatly appreciated

       

      Cheers,

       

      Daniel

        • 1. Re: Value Entered Does Not Match the Format of the Field
          George_Johnson MVP & Adobe Community Professional

          The problem is the division when the denominator evaluates to zero. This result can't be formatted as a number, so you get that error. The fix is to instead use JavaScript and test the denominator before proceeding with the division. If you need help with the script, post again.

          • 2. Re: Value Entered Does Not Match the Format of the Field
            try67 MVP & Adobe Community Professional

            This typically happens when you try to divide by zero, which can also happens if all of the fields are empty (since a blank value is converted to zero behind-the-scenes). To avoid it you would need to convert your calculation formula to a script and make sure that the sum of the hoursXmon fields is not zero before dividing by it.

            • 3. Re: Value Entered Does Not Match the Format of the Field
              Hik5ta Level 1

              Thanks for the replies, the help is much appreciated.

               

              The following code seems to work for me to get the same result as the simplified calculation however I am unsure how to make the script test the denominator before calculating so it is still producing the same error message. Sorry first time trying this so please excuse if the format is incorrect.

               

              event.value = (this.getField("BudgetMon").value / ( this.getField("hours1mon").value + this.getField("hours2mon").value + this.getField("hours3mon").value + this.getField("hours4mon").value + this.getField("hours5mon").value + this.getField("hours6mon").value )) * this.getField("hours1mon").value;

               

              What do I need to add to the script to have it test for 0 before calculating? I would preferably like any empty fields to be displayed blank.

              • 4. Re: Re: Value Entered Does Not Match the Format of the Field
                try67 MVP & Adobe Community Professional

                Use this code:

                 

                var sum = Number(this.getField("hours1mon").value) + Number(this.getField("hours2mon").value) + Number(this.getField("hours3mon").value) + Number(this.getField("hours4mon").value) + Number(this.getField("hours5mon").value) + Number(this.getField("hours6mon").value);
                if (sum==0) event.value = "";
                else event.value = (Number(this.getField("BudgetMon").value) / sum) * Number(this.getField("hours1mon").value);
                
                • 5. Re: Value Entered Does Not Match the Format of the Field
                  Hik5ta Level 1

                  Thank you so much I really appreciate your help, works perfectly!