7 Replies Latest reply on Nov 9, 2010 5:15 AM by AnvilMobile

# Calculating fields

I am having a problem figuring out how to calculate several fields so that they appear as a sum in another field.

Example - I have three fields - Quantity, Unit Cost and Total. I want it so that when I enter a number in the quantity, it will times that number by the unit cost and enter it automatically in the Total field. (The quantity and total are numeric fields, and the unit cost is a text box that cannot be edited, as this will be sent to other people as an order form.)

I have tried it with a form that I exported from Excel, and I can do it in the 'Add or edit fields' tab. However the form I am working on has been created in LiveCycle and there is no option to add or edit fields.

Can anyone give me some help? I can give more detail if necessary

Thanks

• ###### 1. Re: Calculating fields

The unit cost shoudl be a numeric field as well. Then in the Total Field on the Calculate event you can enter this FormCalc formula:

QuantityFieldName * UnitCostFieldName

Paul

• ###### 2. Re: Calculating fields

Thanks very much for your help, I couldn't figure out the forumla either. Is there a way I can lock the unit cost field so it cannot be edited by anyone else, but leave the other fields open?

• ###### 3. Re: Calculating fields

Set the UnitCost field as calculated ReadOnly in the Type dropdown on the Object/Value palette.

Paul

• ###### 4. Re: Calculating fields

Another question:

I am doing an order form, and I would like it so that I can calculate the VAT on a total order (which I have a numeric field for.)

Is there a way of calculating my 'Net Total' numeric field by 17.5% so that it shows up in the VAT field?

EDIT: I have found a way of doing this, although now I cannot figure out how to limit the numeric fields to two decimal places, is there a way to do this?

• ###### 5. Re: Calculating fields

Be sure your field is defined as a Decimal Field, then, in the Object tab, check Limit Trailing Digits and set the value to 2.

• ###### 6. Re: Calculating fields

I have limited the trailing digits and it has worked fine, but I am now stuck with one more problem. When a number is calculated that looks like this - 25.50, it leaves out the '0' at the end and displays it as 25.5. I need to be able to show the second decimal place

• ###### 7. Re: Calculating fields

Play around with the PATTERNS for the field - the display option under the FIELD tab.  It has quite a few different ways it will display that data.  With and without the \$, etc .........  I'm sure one of those will do the trick.