Tuesday, August 14, 2018

Add the values in two or more controls

Add the values in two or more controls

In this article

Overview

Use an expression box to add values in two or more controls

Use a text box to add the values in two or more controls

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.

Adding the values in two controls on an InfoPath form

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

  1. Place the cursor where you want to insert the expression box.

  2. On the Insert menu, click More Controls.

  3. In the Controls task pane, under Advanced, click Expression Box.

  4. In the Insert Expression Box dialog box, click Edit Formula Button image next to the XPath box.

  5. Click Insert Field or Group.

  6. In the folder tree, double-click the first field whose value you want to add.

  7. In the Formula box, type a plus sign (+).

  8. Click Insert Field or Group.

  9. In the folder tree, double-click the second field whose value you want to add.

  10. Repeat steps 7 through 9 for any other fields that you want to add.

  11. 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.

  1. Place the cursor where you want to insert the text box.

  2. On the Insert menu, click Text Box.

  3. In the form template, double-click the text box that you just added.

  4. Click the Data tab.

  5. Under Default Value, click Edit Formula Button image .

  6. Click Insert Field or Group.

  7. In the folder tree, double-click the first field whose value you want to add.

  8. In the Formula box, type a plus sign (+).

  9. Click Insert Field or Group.

  10. In the folder tree, double-click the second field whose value you want to add.

  11. Repeat steps 7 through 9 for any other fields that you want to add.

  12. Click OK two times.

Top of Page

No comments:

Post a Comment