About the data source

Microsoft Office InfoPath

Show All Show All

About the data source

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

You can work with your form’s fields and groups in the Data Source task pane.

Data source task pane in InfoPath

Callout 1Field

Callout 2Group

The controls on your form are bound to the fields and groups in the data source; this binding allows data entered into a control to be saved. Information entered into a bound control is saved in the field it is associated with.

Although the structure of the data source does not always exactly match the layout of your form, similarities are common, particularly for groups and fields associated with repeating tables, sections, repeating sections, and optional sections. In these cases, a table or section is bound to a group in the data source, and all the controls in the table or section are bound to fields that are part of that group. In the following illustration, the Itemized Expenses repeating table consists of three columns containing a Date date picker, a Description text box, and a Cost text box. These controls are bound to a date field, a description field, and an amount field. The table itself is bound to the item group.

Repeating table bound to group and fields in data source

Using the Data Source task pane to insert controls

You can insert controls by dragging fields and groups from the Data Source task pane onto the form. Each time you drag a field or group, Microsoft Office InfoPath 2003 suggests the control that best matches the field or group. If the field has a date data type, for example, InfoPath suggests a date picker. If the group is repeating and contains three fields, InfoPath suggests a repeating table or a repeating section. Remember that you can drag the group that contains a set of fields to automatically create repeating tables, repeating sections, and sections. To see all the control recommendations for a field or group, right-click the field or group in the Data Source task pane.

Modifying fields and groups in the data source

When working directly with the data source in the Data Source task pane, you can add, move, reference, and delete fields and groups. In addition, you can change the following properties of fields and groups in the data source:

  • Name   The name of the field or group. Names cannot contain spaces. They must begin with an alphabetic character or underscore ("_"), and they can contain only alphanumeric characters, underscores, hyphens ("-"), and periods (".").
  • Type   The type of field or group. Options are element field (the standard type of field), attribute field, and group. Fields store data that is entered into controls; groups contain fields and cannot store data.
  • Data type   Defines the kinds of data the field can store. Data types include Text, Rich Text, Whole Number, Decimal, True/False, Hyperlink, Date, Time, Date and Time, and Picture. Only fields can have data types.
  • Default value   The initial value that a field has when the form is first opened by a user. Only fields can have default values.
  • Repeating   Determines whether the field or group can occur more than once in a form. List controls, repeating sections, repeating tables, and controls that are part of a repeating section or repeating table are bound to repeating fields and repeating groups.
  • Cannot be blank   Determines whether the field must contain a value. If the field cannot be blank, any control bound to the field that does not have a value entered into it will be marked with an error alert.

If your users have already filled out forms based on your form template, the following changes can cause data loss in those forms:

  • Moving, deleting, or renaming a field or group
  • Changing a repeating field or group to nonrepeating
  • Changing a rich text data type to a different data type

You can create matching fields and groups for when you want to store the same type of data in more than one place— such as a billing and shipping address in an invoice form. When you reference a field, InfoPath creates a new field whose properties are linked and matched to the properties of the original. Both fields become reference fields, and a change to one field updates the other field automatically. Reference groups, like reference fields, share the same properties; in addition, they contain the same fields and groups.

Relationship between the Data Source and an XML Schema

The forms that users fill out are stored as XML documents. When you create the data source for a form template, you are actually creating an XML Schema, which is an XML-based file that determines the structure of those XML documents. Each group in the data source is an XML element that can contain other elements and attributes, but not data, and each standard field in the data source is an XML element that can contain data. Each attribute field is an XML attribute. You can view additional schema details on the Details tab of the Field or Group Properties dialog box.

Existing XML Schemas, XML documents, databases, and Web services

When you design a form based on an existing XML Schema, InfoPath creates a data source based on the XML Schema. Because existing XML Schemas can be more restrictive than new blank forms, you cannot modify existing fields or groups in the data source. In addition, you might not be able to add fields or groups to part or all of the data source. When you design a form based on an existing XML document, InfoPath creates the data source based on the information in that XML document. The more detailed your XML document is, the more detailed the resulting data source will be.

When you design a new form that is connected to a database or Web service, InfoPath builds a data structure for your form based on the database or the operations of the Web service. The resulting form can be used to submit data to and query the database or Web service. Because the data source must match the database or Web service, you cannot modify existing fields or groups in the data source, and you can add fields or groups only to the root group in the data source.