Display the contents of two fields in one control

Microsoft Office InfoPath

Show All Show All

Display the contents of two fields in one control

You can use expression boxes to display the contents of two fields in one control (or concatenate two fields), as well as 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.

  1. In design mode, place the insertion point where you want to insert the expression box.
  2. If the Controls task pane is not visible, click More Controls on the Insert menu.
  3. In the Controls task pane, click Expression Box.
  4. Enter an expression such as one of the following in the XPath box in the Insert Expression Box dialog box:
    Expression typeExpression
    Display two fields separated by a spaceconcat(my:field1, " ", my:field2)
    Display two fields separated by a commaconcat(my:field1, ",", my:field2)
    Display two fields run togetherconcat(my:field1, my:field2)

    In the preceding table, my:field1 and my:field2 are only examples. When you type your concatenation expression, you must replace the examples with XPath expressions that identify your specific fields. In addition, you can change the text that separates the two fields.

    ShowHow?

  5. To test the formula, click Preview Form on the Standard toolbar.