Applies ToInfoPath 2010 InfoPath 2013

The data source, which stores all of the data that users enter into a form, is made up of fields and groups. In the same way that folders on your hard disk drive contain and organize your files, fields contain the data that users enter into your form, and groups contain and organize those fields. For example, if the data source for your form contains fields for first name, middle name, and last name, those fields can be contained in a group called "name."

In this article

Before you begin

You can add fields or groups only to a form template's main data source. You cannot add fields or groups to a secondary data source or to fields or groups that are based on a database, Web service, or pre-existing XML Schema or XML documents.

Tip: If you see this locked field icon or this locked group icon in the Data source task pane, you cannot modify the field or group.

Each field or group in the data source must have a unique name. If you must use the name of an existing field or group in another field or group, you can add a reference field or reference group to a form template.

You can update your form template by moving or deleting existing fields or groups from the data source. You can move or delete only fields or groups that were added to the main data source. Fields or groups that are based on an XML Schema, database, or Web service, or fields and groups in a secondary data source cannot be moved or deleted.

Note:  When you delete a field, and a control is bound to that field, the control cannot store the data because the field that stores the data no longer exists. Further, if users have already filled out forms based on your form template, deleting a field can cause data loss in those completed forms. If you delete a field, and a control is bound to that field, you must either bind the control to another field or delete the control. Deleting a group deletes all of the fields in that group. Any controls that are bound to the fields in the deleted group must be bound to other fields or be deleted.

Top of Page

Add a field

You can add either an element field or an attribute field to a group in the main data source. You can also add an attribute field to an existing element field in the main data source. However, you cannot add a field to an attribute field.

Add a field to a group

  1. If the Data Source task pane is not visible, click Data Source on the View menu.

  2. If your form template uses more than one data source, select Main in the Data source list.

  3. In the Data source task pane, right-click the group to which you want to add a field, and then click Add on the shortcut menu.

  4. In the Name box in the Add Field or Group dialog box, type a name for the new field. Names must begin with an alphabetic character or underscore (_) and can contain only alphanumeric characters, underscores, hyphens (-), and periods (.). Names cannot contain spaces.

    Use a name that describes the contents of the field. For example, if you have a field that contains the amount of an expense, name the field expense.

  5. In the Type list, select Field (element), or select Field (attribute).

  6. In the Data type list, select the data type that you want to use for the field.

    List of data types for fields

    Data type

    When to use

    Text

    Use this data type for an element or attribute field that contains unformatted text.

    Rich Text

    Use this data type for an element field that contains formatted text. You cannot use this data type for attribute fields.

    Whole Number

    Use this data type for an element or attribute field that contains numbers without decimal values.

    Decimal

    Use this data type for an element or attribute field that contains currency values or numbers with decimal values.

    True/False

    Use this data type for an element or attribute field that contains data that can be only one of two values.

    Hyperlink

    Use this data type for an element or attribute field that contains a Uniform Resource Identifier (URI), such as a hyperlink or a namespace.

    Date

    Use this data type for an element or attribute field that contains a calendar date.

    Time

    Use this data type for an element or attribute field that contains a 24-hour time.

    Date and Time

    Use this data type for an element or attribute field that contains both a calendar date and a 24-hour time.

    Picture or File Attachment

    Use this data type for an element or attribute field that contains binary data, such as an image or a picture.

    Custom

    Use this data type for an element or attribute field with custom data types that are defined by a namespace. This data type is typically used for a field or group that is bound to a custom control. The Data namespace box is enabled when you choose this data type.

    This table shows only the most common XML data types used in a form template. In InfoPath, you can use any XML 1.0 data type in the World Wide Web Consortium (W3C) recommendations. To use a data type that is not listed in the table, you must extract the form files for a form template and edit the schema (.xsd) file. Find links to more information about extracting the form files for a form template in the See Also section.

  7. To specify an initial value that the field should contain when a user first opens the form, type the value in the Default value box. Find links to more information about setting the default value for a field in the See Also section.

  8. To convert an element field into a repeating field, select the Repeating check box.

  9. To require that the field contain a value, select the Cannot be blank check box. If you select this check box, any control that is bound to a field that does not have a value entered into it will be marked with a red asterisk or a dashed red border.

Add an attribute field to an element field

Because you can add only an attribute field to an element field, the Type list in the Add Field or Group dialog box is disabled.

  1. If the Data Source task pane is not visible, click Data Source on the View menu.

  2. If your form template uses more than one data source, select Main in the Data source list.

  3. In the Data source task pane, right-click the field to which you want to add a field, and then click Add on the shortcut menu.

  4. In the Name box in the Add Field or Group dialog box, type a name for the new field. Names must begin with an alphabetic character or underscore (_) and can contain only alphanumeric characters, underscores, hyphens (-), and periods (.). Names cannot contain spaces.

    Use a name that describes the contents of the field. For example, if you have a field that contains the amount of an expense, name the field expense.

  5. In the Data type list, select the data type that you want to use for the field.

    List of data types for fields

    Data type

    When to use

    Text

    Use this data type for an element or attribute field that contains unformatted text.

    Whole Number

    Use this data type for an element or attribute field that contains numbers without decimal values.

    Decimal

    Use this data type for an element or attribute field that contains currency values or numbers with decimal values.

    True/False

    Use this data type for an element or attribute field that contains data that can be only one of two values.

    Hyperlink

    Use this data type for an element or attribute field that contains a Uniform Resource Identifier (URI), such as a hyperlink or a namespace.

    Date

    Use this data type for an element or attribute field that contains a calendar date.

    Time

    Use this data type for an element or attribute field that contains a 24-hour time.

    Date and Time

    Use this data type for an element or attribute field that contains both a calendar date and a 24-hour time.

    Picture or File Attachment

    Use this data type for an element or attribute field that contains binary data, such as an image or a picture.

    This table shows only the most common XML data types used in a form template. In Microsoft Office InfoPath, you can use any XML 1.0 data type in the W3C recommendations. To use a data type that is not listed in the table, you must extract the form files for a form template and edit the schema (.xsd) file. Find links to more information about extracting the form files for a form template in the See Also section.

  6. To specify an initial value that the field should contain when a user first opens the form, type the value in the Default value box. Find links to more information about setting the default value for a field in the See Also section.

  7. To convert an element field into a repeating field, select the Repeating check box.

  8. To require that the field contain a value, select the Cannot be blank check box. If you select this check box, any control that is bound to a field that does not have a value entered into it will be marked with a red asterisk or a dashed red border.

Top of Page

Add a group

  1. If the Data Source task pane is not visible, click Data Source on the View menu.

  2. If your form template uses more than one data source, select Main in the Data source list.

  3. In the Data source task pane, right-click the group to which you want to add a group, and then click Add on the shortcut menu.

  4. In the Name box in the Add Field or Group dialog box, type a name for the new group. Names must begin with an alphabetic character or underscore (_) and can contain only alphanumeric characters, underscores, hyphens (-), and periods (.). Names cannot contain spaces.

    Use a name that describes the contents of the group. For example, if you have a group that contains the itemized details of expenses, name the group ItemizedExpense.

  5. In the Type list, do one of the following:

    • To add a group that can contain other groups or fields, select Group.

    • To add a group that can contain two or more groups of fields, but only one of those groups of fields appears in a view of the form, select Group (choice).

  6. To convert the group into a repeating group, select the Repeating check box.

Top of Page

Add a reference field

If you want to use the name of an existing field for a field in another group in your form template, you can create a reference field. When you create a reference field, InfoPath creates a new field in the form template whose properties are linked and matched to the properties of the original field, including the name and data type. Both fields become reference fields, and any changes that you make to one field update the other field automatically.

Note: Two reference fields cannot be part of the same group. You can add a reference field only to a group. You cannot add a reference field to another field.

  1. If the Data Source task pane is not visible, click Data Source on the View menu.

  2. If your form template uses more than one data source, select Main in the Data source list.

  3. Right-click the field on which you want to base the reference field, and then click Reference on the shortcut menu.

  4. In the Reference Field or Group dialog box, select the group that you want to contain the new reference field.

Top of Page

Add a reference group

If you want to use the name of an existing group for another group in your form template, you can create a reference group. When you create a reference group, InfoPath creates a new group in the form template whose properties are linked and matched to the properties of the original group. Any fields in the first group are duplicated in the reference group. Both groups become reference groups, and any changes that you make to one group, including changes to the fields in that group, update the other group automatically.

Note: Two reference groups cannot be part of the same group.

  1. If the Data Source task pane is not visible, click Data Source on the View menu.

  2. If your form template uses more than one data source, select Main in the Data source list.

  3. Right-click the group on which you want to base the reference group, and then click Reference on the shortcut menu.

  4. In the Reference Field or Group dialog box, select the group that you want to contain the new reference group.

Top of Page

Move a field or group to another location in the main data source

  1. If the Data Source task pane is not visible, click Data Source on the View menu.

  2. If your form template uses more than one data source, select Main in the Data source list.

  3. In the Data source task pane, right-click the field or group that you want to move, and then do one of the following:

    • To rearrange the order of the field or group within its current group, click Move Up or Move Down on the shortcut menu.

    • To move the field or group to a new field or group, click Move on the shortcut menu, and then in the Move Field or Group dialog box, select a new location for the field or group.

Top of Page

Delete a field or group

Note: Deleting a field or group will cause an error in any controls on your form template that are bound to that field or group. In addition, if users have already filled out forms based on your form template, deleting a field or group can cause data loss in those forms.

  1. If the Data Source task pane is not visible, click Data Source on the View menu.

  2. If your form template uses more than one data source, select Main in the Data source list.

  3. Right-click the field or group that you want to delete, and then click Delete on the shortcut menu.

Top of Page

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.