Design a form for merging

With form merging, your users can consolidate data from many different forms into one form. This is useful when your users want to compare or summarize data from several related forms. For example, it can be useful for a manager whose team fills out weekly status report forms to merge data from those forms into a single summary report for her director.

In this article


Ways that users can merge forms

The location of a form determines how a user can merge it with other forms. The following list explains the different locations where Microsoft Office InfoPath forms can be stored and how users can merge forms that are stored in those locations:

  • Local hard disk drive or a network location    A user must first open a form in InfoPath. This form is called the target form because it is the form into which the other forms will be merged. The user then clicks Merge Forms on the File menu, and selects additional forms — called source forms — to merge with the target form.

 Note   You can also open a new, blank form, and then use the same procedure to merge the blank form with additional forms that are based on the same form template.

  • Document library on a SharePoint site    Forms can be stored in a document library on a Windows SharePoint Services 3.0, Microsoft Office SharePoint Server 2007, or Microsoft Office Forms Server 2007 site. On the View menu in the document library where the forms are stored, a user can select the Merge Documents view, and then select the forms that she wants to merge. When merging forms in this way, it is not necessary for a user to first open a target form as described in the previous example.

 Note   When you design a browser-compatible form template (browser-compatible form template: A form template that is designed in InfoPath by using a specific compatibility mode. A browser-compatible form template can be browser-enabled when it is published to a server running InfoPath Forms Services.), users can fill out forms that are based on that form template by using a Web browser. The procedure for merging forms in a SharePoint library that are based on browser-compatible form templates is the same as merging forms that users open and fill out in InfoPath.

  • InfoPath e-mail forms in Microsoft Office Outlook 2007     A user can merge multiple forms from within Office Outlook 2007 by selecting them in the view of the folder where the forms are stored, and then clicking Merge Forms on the Actions menu.

 Note   When users merge forms, the original forms are not deleted. The data from the merged forms is added to the target form. It is recommended that users save the target form, with merged data, as a new form so as not to overwrite the data in the original form.

Top of Page Top of Page

Design considerations

Now that you are familiar with the ways that users can merge forms based on a form's location, it is important to understand how you can enable specific controls to support merging, and how data from individual 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.) is combined when forms are merged. This information — along with an understanding of how your users plan to use merged data — is a key part of creating form templates that enable users to can easily merge forms.

When you add a control to a form template, it is 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 a field or group in the form template's data source (data source: The collection of fields and groups that define and store the data for an InfoPath form. Controls in the form are bound to the fields and groups in the data source.). If you design a new, blank form template, the data source is created for you when you add controls. If you design a form template that is based on an external data source, such as an XML Schema or a Web service, the controls that you add to the form template must be bound to fields or groups in that data source.

When you enable merge settings for a control, you actually enable merge settings for the field or group that the control is bound to. The merge settings vary depending on the field or group and its data type. Certain types of fields or groups do not support merging.

To better understand how form merging works, imagine that you designed an expense report form template that contains a text box control bound to a non-repeating field in the data source that uses a text data type. This field is used to store each user's business justification for the recorded expenses. For this example, we will call the field purpose and bind the text box control with the label Business Purpose to it.

Control on a form template and its field in the data source.

Imagine that three users — Bob Kelly, Nate Sun, and Judy Lew — are filling out forms based on your form template. In the Business Purpose field, Bob types Conference, Nate types Customer Visit, and Judy types Business Trip. Because text box controls that use a text data type do not support the merging of data by default, a manager who merges these expense report forms will only see one value in the Business Purpose field — the value that was already contained in the target form. So, for example, if Judy's form is the target form, only the value that Judy entered will appear in the merged form for this field.

By customizing the merge settings for the field or group that a control is bound to, users can merge that field's or group's data from multiple forms. In this example, you can customize the merge settings for the Business Purpose text box control so that users can merge data from the forms that contain that field. You can customize the merge settings further by enabling a separator to appear between each merged value. A separator can be a space, a comma, a semicolon, a vertical line, a line break, a paragraph break, or an underline. For example, if Bob types Conference in the Business Purpose field, Nate types Customer Visit, and Judy types Business Trip, and you enable merging for that field, and specify a comma separator, the resulting merged data will display as Business Trip, Customer Visit, Conference (if Judy's form is the target form).

Field showing merged data.

 Note   A space is automatically added after comma and semicolon separators.

While adding a separator can help distinguish between specific values, you can further customize how data is merged by adding a unique prefix to each value that is contained in a field or group. When adding a prefix, you can select the value from another field, or enter a function (function: A predefined XPath expression that returns a value based on the results of a calculation.) that you want to use as a prefix. Adding a prefix can help your users identify the source of the original data. For example, you can enable the name of the person who filled out a form — a value that is entered in another field  — to appear as a prefix for a value contained in another field. Then, when several forms are merged, the values from the source form will display merged values, and those values will have identifiers.

For example, if you identify a field that stores a user's name as the prefix, and create a concat function that adds a colon after each instance of that value, users can easily see who entered a value even after several forms are merged. In this example, if Judy Lew's form is the target form, the resulting prefixed data will appear as Business Trip, Nate Sun: Customer Visit, Bob Kelly: Conference.

Control showing merged data.

 Notes 

  • The prefix is not added to the target form — Judy Lew's form, in this case — to avoid the addition of redundant prefixes if the merged data is saved in the form, and then the form is merged again.
  • When a user merges InfoPath forms that are located on a hard disk drive or a network location, a SharePoint site, or InfoPath e-mail forms in Office Outlook 2007, the resulting merged data is shown in reverse order from the order that the forms were selected. For example, if a user selects three forms, starting with Bob's, then selects Judy's, and then Nate's, in the resulting form that contains merged data, Nate's data will appear first, followed by Judy's data, and then Bob's.
  • In addition to customizing merge settings for individual controls, you can also disable form merging for the entire form template to prevent users from merging forms that are based on it. When you disable form merging, users who fill out the form do not have access to the Merge Forms command on the File menu.
  • To ensure that your form template is configured correctly to merge other forms, test it by publishing the form template, and then creating and saving at least five forms based on the form template with sample data. After saving the forms, open the form template in design mode, and then click Preview on the Standard toolbar.. In preview mode, merge your sample forms. If the forms merge correctly, you can publish the form template and allow your users to create forms based on your form template.
  • Provide users with a procedure on how to merge forms. You can develop this procedure when you test your form template for merging.

Top of Page Top of Page

Merge actions for fields and groups

The following merge actions vary, depending on the data type of the field or group.

When you configure merge settings for any type of field or group, you can either choose to ignore the values in the source forms and keep the values in the target form, or choose a custom merge setting. The following table describes the custom merge settings for each type of field or group.

Field or group type Available merge settings Examples of controls that can be bound to this field type
Non-repeating field
  • Combine the value in the target form with the values from the source forms
    • Ignore blank fields
    • Add a separator between items
    • Add a prefix to each item
  • Text box
  • Drop-down list box
  • Combo box
Repeating field
  • Insert the values from the source forms before or after the value in the target form
    • Remove blank fields
  • Bulleted list
  • Numbered list
  • Plain list
  • Multiple-selection list box
Non-repeating XHTML field
  • Combine the value in the target form with the values from the source forms
    • Ignore blank fields
    • Add a separator between items
    • Add a prefix to each item and format the prefix text
Rich text box
Repeating XHTML field
  • Insert the values from the source forms before or after the value in the target form
    • Remove blank fields
  • Bulleted list
  • Numbered list
  • Plain list
  • Repeating table
Attribute field
  • Replace the value in the target form with the value from the source form

If a user selects multiple forms, the value from the last form that the user selects will be the value that is preserved in the target form. For example, if a user selects three forms, starting with Bob's, then selects Judy's, and then Nate's, the data from the attribute field that is in Nate's form will replace the original value in the target form.

 Note   Depending on the operating system of the person who merges forms, the preserved value may differ.

  • Combine the value in the target form with the values from the source forms
    • Ignore blank fields
    • Add a separator between items
    • Add a prefix to each item
Any control can have an attribute field type.
Non-repeating group
  • Combine the value in the target form with the values from the source forms
  • Section
  • Optional section
Repeating group
  • Insert the values from the source forms before or after the value in the target form
    • Remove blank fields
  • Bulleted list
  • Numbered list
  • Plain list
  • Multiple-selection list box
  • Repeating table

Top of Page Top of Page

Defining custom merge settings for controls

Use the procedures in this section to define custom merge settings for standard and repeating controls.

 Note   When you enable merge settings for a control, you actually enable merge settings for the field or group that the control is bound to. The merge settings vary depending on the field or group and its data type. Certain types of fields or groups do not support merging. You can also change merge settings by editing the properties for a field or group in the data source. To do this, right-click a field or group in the Data Source task pane, click Properties on the shortcut menu, and then on the Rules and Merge tab, click Merge Settings.

Standard controls include the controls that you typically associate with collecting and displaying information. These controls include text boxes, list boxes, check boxes, and buttons. Repeating and optional controls include list controls, repeating tables, repeating sections, and optional sections. These controls allow users to insert list items, rows, record sets, and optional information when filling out a form. For example, in an expense report form template, you can use a repeating table to allow users to add as many rows as they need to enter their specific number of expense items.

 Notes 

Define custom merge settings for standard controls

Standard controls include text boxes, rich text boxes, and combo boxes. See Merge actions for fields and groups in this article for more information.

 Note   Controls that are added inside sections — in other words, child controls of parent controls — only support merging if it has been enabled for the parent control.

  1. Double-click the control that you want to modify.
  2. In the Control Properties dialog box, click the Advanced tab.
  1. Under Merging forms, click Merge Settings.
  1. Under Action for this field, click Combine the value in the target form with the values from the source forms.
  2. To exclude fields that do not contain data, under Combine options, select the Ignore blank fields (recommended) check box.
  3. In the Separate each item with list, choose a separator to appear between the values in the control that appears in the target form.

ShowTechnical details

Adding a separator can help your users determine the user that entered data when data from multiple forms are merged. For example, choosing Comma (",") for a particular control will result in data from that control being separated by commas when multiple forms based on the form template are merged.

  1. To add a prefix before each value that appears in the control when users merge forms based on this form template, select the Prefix each item with check box, and then choose an item that you want to base the prefix on.

ShowHow?

  1. Click Insert Formula Button image.
  1. In the Insert Formula dialog box, do one of the following:
    • To use a field in the formula, click Insert Field or Group, click the field that you want to use in the Select a Field or Group dialog box, and then click OK.
    • To use a function in the formula, click Insert Function, select the function that you want to use from the Insert Function dialog box, and then click OK.

 Tip   If the function requires parameters, select the function in the Insert Function dialog box, click OK, and then in the Formula box in the Insert Formula dialog box, double-click the function that you added, and click a field or group. Find links to more information about functions in the See Also section.

  • To insert a value or mathematical operator into the formula, type the value or the symbol for the mathematical operation in the Formula box.
Operation Symbol
Add +
Subtract -
Multiply *
Divide /
  •  Note   If your formula uses the division (/) operator, make sure that there is a space before and after the division operator. If the division operator does not have a space before and after it, InfoPath may interpret "/" as a separator for XPath location steps rather than as a division operator.

  1. To check the formula for the correct syntax, in the Insert Formula dialog box, click Verify Formula.

Define custom merge settings for a standard section

Standard sections are containers for other controls. Sections can include any of the controls listed in the Controls task pane, including other sections. See Merge actions for fields and groups in this article for more information.

 Note   Controls that are added inside sections — in other words, child controls of parent controls — only support merging if it has been enabled for the parent control.

  1. Double-click the section that you want to modify.
  2. In the Section Properties dialog box, click the Advanced tab.
  3. Under Merging forms, click Merge Settings.
  1. Under Action for this group, click Combine the contents of the groups in the source and target forms (default).

 Note   The merge settings for each field and group within this group will determine how the data is merged.

Define custom merge settings for repeating controls and sections

Repeating controls include repeating sections, repeating tables, and bulleted lists. See Merge actions for fields and groups in this article for more information.

 Note   Controls that are added inside sections — in other words, child controls of parent controls — only support merging if it has been enabled for the parent control.

  1. Double-click the control that you want to modify.
  2. In the Control Properties dialog box, click the Advanced tab.
  1. Under Merging forms, click Merge Settings.
  1. Under Action for this repeating group, click Insert the groups from the source forms into the target form (default).
  2. To determine where the groups from the source forms will appear in the target form, under Insert options, click After groups in the target form or Before groups in the target form.
  3. To eliminate blank values from the merged forms, select the Remove blank groups (recommended) check box.
  4. To combine groups whose controls contain the same values, thereby reducing redundancy, select the Combine groups with the same field value check box, and then click the button next to Fields to compare to select the fields to combine.

Define custom merge settings for optional sections

Optional sections contain other controls. Users can insert or remove optional sections when filling out a form. See Merge actions for fields and groups in this article for more information.

 Note   Controls that are added inside sections — in other words, child controls of parent controls — only support merging if it has been enabled for the parent control.

  1. Double-click the control that you want to modify.
  2. In the Control Properties dialog box, click the Advanced tab.
  1. Under Merging forms, click Merge Settings.
  1. Under Action for this group, click Combine the contents of the groups in the source and target forms (default).

Top of Page Top of Page

 
 
Applies to:
InfoPath 2007