Inserting the subtotal at the bottom of the table

To perform calculations, FormCalc needs to know what object to use in the calculation. In this step, we want to find out the total of all the data in the Amount column. If you select a cell in the Amount column, you can see the internal name in the Script Editor (if you resize the Script Editor to be larger).

What you see in the internal name relates to what you see in the hierarchy. “PurchaseOrderForm” is at the top, followed by “PurchaseOrder”, and so on.

All the rows in the table are named “Row1” followed by a default instance number. To be able to add the data in one column, all the rows have to be named the same.

Now, you will add the calculation for the subtotal at the bottom of the table.

  1. In the Object Library palette, click the Standard category and then drag the Numeric Field object  onto the form below the table under the Amount column.

  2. Select the caption text in the Numeric Field object and type Total .

  3. In the Object palette, click the Field tab and select Solid Box form the Appearance list.

  4. In the Script Editor, select Calculate from the Show list.

  5. Select FormCalc from the Language list and Client from the Run At list.

  6. In the Script Source field, type the following calculation:

    sum(Table1.Row1[*].amount[*])

    The wildcard character (*) tells Designer to collect all the data in the rows labeled Row1 and all the data in the Amount column.

  7. Deselect the Numeric Field object to add the script to your form, then select it again.

  8. In the Object palette, click the Binding tab and type total in the Name box.

  9. Click the Field tab, click the Patterns button, and in the Pattern box, type $z,zz9.99.

  10. Click OK.

  11. Click the Value tab and in the Type list, select Calculated - Read Only.

Click to continue: Inserting the Tax fields

// Ethnio survey code removed