About the data source

Microsoft Office InfoPath 2003

Show All Show All

About the data source

The data source, which stores all of 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, fields contain the data in your form, and groups contain and organize those 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 1 Field

Callout 2 Group

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. For example, a table or section is bound to a group in the data source, and all of 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 your form. Each time you drag a field or group onto your form, Microsoft Office InfoPath 2003 suggests the control that best matches that field or group— that is, the control that accepts the type and structure of data associated with the field or group. If the field has a date data type, for example, InfoPath suggests you insert a date picker control. If the group is repeating and contains three fields, InfoPath suggests a repeating table or a repeating section.

ShowTip

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:

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. Types include element field (the standard type of field), attribute field, group, choice group, and complete XML document or Schema. Fields store data that is entered into controls; groups contain fields and cannot store data. Choice groups store data associated with choice group controls. You can use the complete XML document or Schema type to add XML documents or XML Schemas to a specific part of the data source.

Data type   Defines the kinds of data that the field can store. Data types include Text, Rich Text, Whole Number, Decimal, True/False, Hyperlink, Date, Time, Date and Time, Picture, and Custom, which is for fields associated with Microsoft ActiveX controls. Only fields can have data types.

Default value   The initial value that a field has when the form is first opened by a user. You can also add formulas to default values, such as the current date, a mathematical calculation, or a reference to another field.

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 a red asterisk or, for some types of controls, a dashed red border.

Note  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 a nonrepeating field or group
  • Changing a rich text data type to a different data type

If 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— you can create matching fields and groups. When you reference a field, InfoPath creates a new, identical field whose properties are linked to the properties of the original field. 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.

Understanding the 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, 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 in 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 that is based on that XML Schema. The more detailed your XML document is, the more detailed the resulting data source will be. Because using an existing XML Schemas can be more restrictive than designing a new, blank form, you cannot modify existing fields or groups in the data source. In addition, depending on the structure of the XML Schema, you might not be able to add fields or groups to part or all of the data source.

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 that database or Web service. The resulting form can be used to query or submit data to the database or Web service. Because the data source must match the database or Web service, you can only modify new fields or groups in the data source, and you can add fields or groups only to the root group in the data source.

Secondary data sources and data connections

In addition to the main data source for your form, you can create data connections to XML documents, databases, Web services, or Microsoft Windows SharePoint Services libraries and lists. These data connections result in secondary data sources, which can be used to populate list boxes, and provide the values for text boxes and other controls. With some exceptions, including specifying default values and direct editing of the fields and groups, you can work with secondary data sources in the same way that you work with the form's primary data source. In addition, you can query and submit data using data connections. For more information about data connections, see About data connections.

Note  The information in this topic may not apply if you are working with a form designed using Microsoft Office InfoPath 2003 without the service pack installed. Learn more