Pre-select items in a Multiple-Selection List Box in InfoPath 2010
Learn how to use default values to pre-select items in a multiple select list box in InfoPath 2010.
You have an InfoPath multiple-selection list box on a form and you would like to pre-select items, that is, have a few items in the list appear selected when the InfoPath form opens for the first time.
Add Default Values to the InfoPath multiple-selection list box, so that items are automatically selected when the InfoPath form is opened for the first time.
You can pre-select items in a multiple select list box in InfoPath 2010 as follows:
- In InfoPath Designer 2010, create a new Blank Form template.
- On the Home tab in the Controls group, click Multiple-Selection List Box to add the control to the InfoPath form template.
- Follow steps 2 through 5 of the article to create an InfoPath XML data connection to an XML file in InfoPath 2010 to add a data connection to an XML file to the InfoPath form template.
- Click on the Multiple-Selection List Box to select it.
- On the Properties tab under the Properties group, click Control Properties.
- On the Multiple-Section List Box Properties dialog box under the List box choices, select the Get choices from an external data source radio button.
- The data source you created previously should be automatically selected in the Data source drop-down list box. If not, select it from the Data source drop-down list box.
- Click the button behind the Entries text box.
- On the Select a Field or Group dialog box, select a repeating group, and click OK.
- On the Multiple-Section List Box Properties dialog box, select appropriate fields for the Value and Display name, and then click OK.
In the example in this article, the list box will contain the names of running shoe brands such as Mizuno, ASICS, Brooks, Saucony, and New Balance.
To display a few items (for example, Mizuno and Saucony) pre-selected when the InfoPath form opens:
- On the Data tab under the Form Data group, click Default Values.
- On the Edit Default Values dialog box, expand group1.
- Click field1, and then type one of the values that you want to pre-select in the Default value text box. In our example, we'll type Mizuno.
- Right-click on field1, and then select Add another field1 below from the context menu that appears.
- Type the second value that you want to pre-select in the Default value text box. In our example, we'll type Saucony.
Figure 1. Edit Default Values dialog box in InfoPath 2010.
- Continue adding as many field1 nodes as you require for pre-selecting values in the Multiple-Selection List Box. Click OK when you're done.
Press F5 to preview the InfoPath form. The items pertaining to the values that you entered as Default Values should now appear selected in the Multiple-Selection List Box when the forms opens.
Figure 2. Pre-selecting items in a Multiple-Selection List Box in InfoPath 2010.
This solution also works with the 2 other list box choices, that is, Enter choices manually and Get choices from fields in this form. This solution is independent of the data source you choose to use, but it is recommended that any Default Values you specify exist in the data source that is bound to the InfoPath Multiple-Selection List Box.
Copyright: This article may not be used on web sites (whether personal or otherwise), copied, disseminated, altered, printed, published, broadcasted, or reproduced in any way without an expressed written consent of S.Y.M. Wong-A-Ton. The techniques demonstrated in this article may be used within any Microsoft InfoPath project. This article is provided without any warranties. Copyright for this article is non-transferrable and remains with the author, S.Y.M. Wong-A-Ton.
Related InfoPath Articles:
- Understanding the Multiple-Selection List Box in InfoPath
- Create text boxes for items selected in a multiple-selection list box in InfoPath 2010
- Use a SharePoint list for dependent multi-select list boxes on an InfoPath 2010 browser form
- Cascading multiple-selection list boxes in InfoPath 2010
- Limit a multi-select list box to a maximum of 3 selected items