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.
-
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.
-
Select the caption text in the Numeric Field object and type
Total
.
-
In the Object palette, click the Field tab and select Solid
Box form the Appearance list.
-
In the Script Editor, select Calculate from the Show list.
-
Select FormCalc from the Language list and Client from the
Run At list.
-
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.
-
Deselect the Numeric Field object to add the script to your
form, then select it again.
-
In the Object palette, click the Binding tab and type
total
in
the Name box.
-
Click the Field tab, click the Patterns button, and in the
Pattern box, type
$z,zz9.99.
-
Click OK.
-
Click the Value tab and in the Type list, select Calculated
- Read Only.
Click to continue:
Inserting the Tax fields
|
|
|