Formulas are stored in fields (field: An element or attribute in the data source that can contain data. If the field is an element, it can contain attribute fields. Fields store the data that is entered into controls.) and are displayed in the controls that are bound (bind: To connect a control to a field or group in the data source so that data entered into the control is saved. When a control is unbound, it is not connected to a field or group, and so data entered into the control will not be saved.) to those fields. When designing a form, you can create formulas in text boxes, rich text boxes, date pickers, and expression boxes.
Note You should use an expression box only if you do not want to use the result of the formula in another formula or save it as part of a form, because expression boxes only display data and do not store it.
- In design mode, double-click the control where you want to create the formula.
- On the Data tab in the Control Properties dialog box, click Insert Formula .
Note To create the formula by using the field's properties, right-click the field in the Data Source task pane, and then click Properties.
- In the Insert Formula dialog box, do one or more of the following:
- To insert a field or group in the formula, click Insert Field or Group, and then click the field or group (group: An element in the data source that can contain fields and other groups. Controls that contain other controls, such as repeating tables and sections, are bound to groups.) in the Select a Field or Group dialog box.
- To insert a function (function: A predefined XPath expression that returns a value based on the results of a calculation.) in the formula, click Insert Function, and then select the function in the Insert Function dialog box. If the function requires an argument (argument: A value that provides information to an action, an event, a method, a property, a function, or a procedure.), double-click the function in the Formula box, and then click a field or group.
- To insert a value or mathematical operator in the formula, type the value or symbol for the mathematical operation in the Formula box. The symbols appear in the following table (note that you should include spaces around the division symbol).
Mathematical formulas usually depend on integer or decimal values as arguments. To avoid blank values, select the Treat blank values as zero check box on the General tab in the Form Options dialog box.
Note The information in this topic may not apply if you are working with a form designed using Microsoft Office InfoPath 2003 without the service pack installed.