Add the values in two or more controls
In this article
Overview
If you have two or more controls in your form template whose values you want to add, you can add an expression box or a text box that performs the calculation. For example, you might have a reservation form template that contains a text box where users enter the number of adults attending an event, and another text box where users add the number of children attending. You can add a third control that automatically calculates the total number of people attending the event.
If you only want to display the results of the calculation, and you do not want to use the results of the calculation in other calculations, use an expression box to perform the calculation. An expression box only displays data and does not store it. If you want to use the results of the calculation in another calculation, use a text box.
Find a link to more information about how to add columns of values in a repeating table or repeating section in the See Also section.
Use an expression box to add values in two or more controls
-
Place the cursor where you want to insert the expression box.
-
On the Insert menu, click More Controls.
-
In the Controls task pane, under Advanced, click Expression Box.
-
In the Insert Expression Box dialog box, click Edit Formula next to the XPath box.
-
Click Insert Field or Group.
-
In the folder tree, double-click the first field whose value you want to add.
-
In the Formula box, type a plus sign (+).
-
Click Insert Field or Group.
-
In the folder tree, double-click the second field whose value you want to add.
-
Repeat steps 7 through 9 for any other fields that you want to add.
-
Click OK two times.
InfoPath adds the expression box to the form template.
Use a text box to add the values in two or more controls
Note: You can use a rich text box to perform a numeric calculation. The procedure is very similar to that for using a text box. However, because numeric calculations do not include text, there is no real advantage to using a rich text box over a regular text box.
-
Place the cursor where you want to insert the text box.
-
On the Insert menu, click Text Box.
-
In the form template, double-click the text box that you just added.
-
Click the Data tab.
-
Under Default Value, click Edit Formula .
-
Click Insert Field or Group.
-
In the folder tree, double-click the first field whose value you want to add.
-
In the Formula box, type a plus sign (+).
-
Click Insert Field or Group.
-
In the folder tree, double-click the second field whose value you want to add.
-
Repeat steps 7 through 9 for any other fields that you want to add.
-
Click OK two times.
No comments:
Post a Comment