Count the instances of a field
You can use expression boxes to count the instances of a field and perform other calculations. When you create formulas in an expression box, you refer to the fields and groups to which controls on the form are bound, rather than the controls themselves. The formulas are created using XPath, but you can follow these steps without knowing XPath.
- In design mode, place the insertion point where you want to insert the expression box.
- If the Controls task pane is not visible, click More Controls on the Insert menu.
- In the Controls task pane, click Expression Box.
- Enter an expression such as the following in the XPath box in the Insert Expression Box dialog box:
count(my:group1/my:group2/my:field3)Note In this expression, my:group1/my:group2/my:field3 is only an example. When you type your count expression, you must replace the example with an XPath expression that identifies your specific field.
- In the Insert Expression Box dialog box, click Select XPath .
- In the Select a Field or Group dialog box, select the field whose instances you want to count, and then click OK.
Note The field must be a repeating field or part of a repeating group.
- In the Insert Expression Box dialog box, wrap the text in the XPath box with the following expression: count(text )
- Before the text in the XPath box, type count(
- After the text, type )
- To test the formula, click Preview Form on the Standard toolbar.