Insert a repeating table
If you want users to be able to enter information in a table, you can add a repeating table to your Microsoft Office InfoPath form template. Repeating tables usually display one row by default. When filling out a form that is based on your form template, users can insert additional rows into the table as they need them. If your form template includes a data connection to an external data source, such as a database, you can use a repeating table to automatically display multiple records on the form.
In this article
When to use a repeating table
Use a repeating table when you want to:
-
Enable users to enter data in a structured, tabular format.
-
Collect line items, numerical data, and other types of data that are best displayed in a table.
-
Conserve space on your form template by displaying only as many rows as contain actual data.
-
Display or work with records from a database, Web service, or other data source in a table on the form template.
In the following image, a repeating table is used to collect line items on an expense report form.
A repeating table consists of three parts:
-
Header row When you insert a repeating table in a new, blank form template, the header row appears by default. You typically use the header row for column headings. If you don't need column headings, clear the Include header check box in the Repeating Table Properties dialog box.
-
Data row The data row is the row that can "repeat" in the form as many times as necessary. As the form template designer, you will see just a single row in design mode when you insert a repeating table. The person who fills out a form that is based on your form template, however, can add multiple rows in the form by pressing CTRL+ENTER, by clicking commands on a shortcut menu, or by clicking Insert item underneath the last row of the table.
-
Footer row You can use the footer row to add text boxes or expression boxes that sum the values in a column. The footer row doesn't appear in the repeating table by default. To turn the footer row on, select the Include footer check box in the Repeating Table Properties dialog box.
Related controls
InfoPath includes other controls that are similar to repeating tables but that serve different purposes. To decide which of these controls works best on your form template, refer to the following list:
Repeating section To create a less structured section that users can insert on a form multiple times (such as a record in a database), use a repeating section instead of a repeating table.
Horizontal repeating table When you want users to be able to add extra columns to a table instead of extra rows, you can use a horizontal repeating table instead of a regular repeating table.
The user experience
A shortcut menu button appears whenever users move their pointer over a row in a repeating table. Users click the button to see a shortcut menu of commands for inserting or removing a row.
Users can also insert a new row by clicking the Insert item text that appears below the repeating table on the form. You can customize or remove this text when designing your form template.
Insert a repeating table
The procedure for inserting a repeating table differs slightly depending on whether you are designing a new, blank form template or basing the design of your form template on a database or other external data source.
The following illustration shows how a repeating table looks in design mode.
Controls can be bound or unbound. When a control is bound, it is connected to a field or group in the data source so that data entered into the control is saved in the underlying form (.xml) file. When a control is unbound, it is not connected to a field or group, and data entered into the control is not saved. When you select or move your pointer over a control, text and a binding icon appear in the upper-right corner of the control. The text indicates the group or field to which the control is bound in the data source. The icon indicates whether the control is correctly bound to that group or field. When the binding is correct, a green icon appears. If there's something wrong with the binding, you'll see a blue or red icon instead.
The data source for the form template consists of fields and groups that appear in a hierarchical view in the Data Source task pane. Repeating tables are usually bound to repeating groups in the form template's data source, although they can also be bound to repeating fields.
In the following example, the Itemized Expenses table on the form is bound to the item repeating group in the Data Source task pane. The text box controls within the table — Date, Description, Category, and Cost — are bound to fields that are part of the item repeating group.
Insert a repeating table on a new, blank form template
When you design a new, blank form template, the Automatically create data source check box in the Controls task pane is selected by default. This enables InfoPath to automatically create fields and groups in the data source as you add controls to the form template. These fields and groups are represented by folder and file icons in the Data Source task pane.
-
On the form template, place the cursor where you want to insert the control.
-
If the Controls task pane is not visible, click More Controls on the Insert menu, or press ALT+I, C.
-
Under Insert controls, click Repeating Table.
-
In the Number of columns box, enter the number of columns that the table should have.
-
The repeating table is created with a text box in each column. To convert a text box to a different type of control, right-click the text box, point to Change To on the shortcut menu, and then click the control that you want.
Insert a repeating table on a form template that is based on an existing data source
If you base the design of your form template on an existing Extensible Markup Language (XML) file, database, or Web service, InfoPath derives the fields and groups in the Data Source task pane from that existing data source. In this scenario, you can insert a repeating table by dragging a repeating group from the Data Source task pane onto the form template, or by inserting a repeating table from the Controls task pane instead, as described in the following procedure:
-
On the form template, place the cursor where you want to insert the control.
-
If the Controls task pane is not visible, click More Controls on the Insert menu, or press ALT+I, C.
-
Under Insert controls, click Repeating Table.
-
On the first page of the Repeating Table Binding Wizard, click the data source that you want to use in the Data source list, and then click the repeating group that you want to bind the table rows to.
Tip: To create a new repeating group, right-click the group to which you want to add the repeating group, click Add on the shortcut menu, and then in the Add Field or Group dialog box, specify the properties for the repeating group.
-
Click Next.
-
On the second page of the Repeating Table Binding Wizard, double-click the fields in the Data binding list that you want to add as columns to the table.
Tip: To create a new field in the Data binding list, right-click the group to which the repeating table is bound, click Add on the shortcut menu, and then in the Add Field or Group dialog box, specify the properties for the field.
-
To reorder the columns, select a column in the Columns in table list, and then click Move Up or Move Down.
Layout tips
Use the following tips to help you refine the appearance, size, and other aspects of the controls inside a repeating table:
-
To change the size of several text boxes at once, select the text boxes whose size you want to change, on the Format menu, click Properties, and then make the necessary adjustments on the Size tab.
-
Resize the text boxes on your form template to accommodate the length of the text that you expect users to type in the boxes.
-
To change the border or color of the controls in the repeating table, select the text boxes that you want to change, on the Format menu, click Borders and Shading, click the Borders tab, and then make the necessary adjustments.
-
To customize the text that appears in a text box inside a repeating table, use the Font and Font Size boxes on the Formatting toolbar. To change the font and font size for all of the text boxes on your form template at once, select the text box that contains the formatting that you want, and then click Apply Font to All Text Box Controls on the Format menu.
-
To see what your text boxes will look like with actual text in them, click Sample Data on the View menu. This helps you get a sense of what a form that is based on your form template will look like when users fill it out.
No comments:
Post a Comment