Wednesday, September 29, 2010

Cruising the Calculate tab

Like its Format and Validate tab brethren, options on the Calculate tab apply only to Combo box and Text field types. You use these commands to perform mathematical calculations on data entered in two or more form fields and display the result in another field. This feature is often used in an interactive order form where the product of an item’s quantity and price is automatically displayed in a total field. In addition, it’s possible to perform more advanced calculations using JavaScript.
To define the fields in a form that will perform calculations or attach a JavaScript calculation to a field, select one of the three radio buttons on the Calculate tab:
  • Value Is Not Calculated: The default state. Select this option if you don’t want to perform a calculation on data entered in a field.
  • Value Is the of the Following Fields: Provides a drop-down list of five operations: sum (+), product (), average, minimum, and maximum. Select an operation option and then click the Pick button to open the Field Selection dialog box, which displays a list of fields in your form. Select a field’s check box in the Select Fields for Calculation list box. You can select more than one field at a time, and you can select or deselect all the fields by clicking the appropriate button. When you’re finished selecting fields, click the OK button.
  • Custom Calculation Script: Click the Edit button to open the JavaScript Edit window. If you’re familiar with JavaScript language, you can write your own or copy and paste a predefined JavaScript in the script editing window. Click OK to close the JavaScript Edit window. The calculation script appears in a preview box below the Custom Calculation Script radio button. Note that you can use the arrow keys to view the script, but you can’t edit it.
By default, field calculations are performed in the same order as the form field’s tab order — that is, the order in which the fields are selected when the user presses the Tab key. This is not always a good idea, especially if your form contains multiple calculations where the result of one calculation depends on the result of another calculation. To override the default, set your own calculation order by choosing Advanced➪Forms➪Set Field Calculation Order to open the Calculated Fields dialog box. Select fields in the window and use the Up and Down buttons to arrange their calculation order, and then click OK to save your changes.

0 comments: