Insert a list box
You can create a list box or drop-down list box on your form so users can easily and accurately enter predefined values. List boxes are bound to fields, and they can look up their values in a fixed list, an XML document, a Microsoft Access database or Microsoft SQL Server database, or a Web service.
Insert a list box that looks up values in a fixed list
- In design mode, place the insertion point where you want to insert the list box.
- If the Controls task pane is not visible, click More Controls on the Insert menu.
- In the Controls task pane, do one of the following:
- If you want Microsoft Office InfoPath 2003 to automatically create a field in the data source that is bound to the list box, make sure the Automatically create data source check box is selected.
- If you want to bind the list box to an existing field, make sure the Automatically create data source check box is cleared.
Note If the check box cannot be selected, the form's design does not allow the data source to be automatically created.
- Click List Box or Drop-Down List Box.
- If you cleared the Automatically create data source check box in step three, select a field in the Binding dialog box to bind the list box to.
- Double-click the list box on the form.
- On the Data tab, click Add.
- In the Value box, type the text that you want to store if a user selects this entry.
- In Display name box, type the text that you want to display for this entry, and then click OK.
- Repeat steps seven through nine for each entry you want to add to the list box.
- To test the list box, click Preview Form on the Standard toolbar.
Insert a list box that looks up values in an XML data file
- In design mode, place the insertion point where you want to insert the list box.
- If the Controls task pane is not visible, click More Controls on the Insert menu.
- In the Controls task pane, do one of the following:
- If you want Microsoft Office InfoPath 2003 to automatically create a field in the data source that is bound to the list box, make sure the Automatically create data source check box is selected.
- If you want to bind the list box to an existing field, make sure the Automatically create data source check box is cleared.
Note If the check box cannot be selected, the form's design does not allow the data source to be automatically created.
- Click List Box or Drop-Down List Box.
- If you cleared the Automatically create data source check box in step three, select a field in the Binding dialog box to bind the list box to.
- Double-click the list box on the form.
- On the Data tab, click Look up in a database, Web service, or file, and then click Secondary Data Source.
- In the Secondary Data Sources dialog box, click Add.
Note If you already added the XML data file as a secondary data source, you can select it in this dialog box.
- Follow the instructions in the Data Source Setup
Wizard.
- Click XML data file, and then click Next.
- On the second page of the wizard, enter the location of the XML data file, and then click Next.
- On the third page of the wizard, type a name for the secondary data source, and then click Finish.
- In the dialog box that asks if you want to add the file to your form, click Yes.
- In the Secondary Data Sources dialog box, click Close.
- The entries in the list box must be associated with a particular repeating group or repeating field in the XML data file. Click Select XPath to the right of the Entries box, and then select the group or field that contains the fields that provide the values displayed in the list box.
- Click Select XPath to the right of the Value box, and then select the field that contains the values stored in the form when a user clicks an item in the list box.
- Click Select XPath to the right of the Display name box, and then select the field that contains the values displayed in the list box.
Insert a list box that looks up values in a database
- In design mode, place the insertion point where you want to insert the list box.
- If the Controls task pane is not visible, click More Controls on the Insert menu.
- In the Controls task pane, do one of the following:
- If you want Microsoft Office InfoPath 2003 to automatically create a field in the data source that is bound to the list box, make sure the Automatically create data source check box is selected.
- If you want to bind the list box to an existing field, make sure the Automatically create data source check box is cleared.
Note If the check box cannot be selected, the form's design does not allow the data source to be automatically created.
- Click List Box or Drop-Down List Box.
- If you cleared the Automatically create data source check box in step three, select a field to bind the list box to.
- Double-click the list box on the form.
- On the Data tab, click Look up in a database, Web service, or file, and then click Secondary Data Source.
- In the Secondary Data Sources dialog box, click Add.
- Follow the instructions in the Data Source Setup Wizard.
- Click Database (Microsoft SQL Server or Microsoft Access only), and then click Next.
- On the second page of the wizard, click Select Database, and then, in the Select Data Source dialog box, browse to and select the SQL Server or Access database you want to base the form on, and click Open.
Note If there is more than one table in your database, click the table that you want to have as the primary parent table for your form in the Select Table dialog box, and then click OK.
- In the Data Source Setup Wizard, click Next.
- On the third page of the wizard, type a name for the database connection in the Enter a name for this data source box.
- If you want the form to always connect to the database when the form is opened, select the Connect to this secondary data source when the form is opened check box.
- Click Finish.
- In the Secondary Data Sources dialog box, click Close.
- The entries in the list box must be associated with a particular table in the database. Click Select XPath to the right of the Entries box, and select the table (group) that contains the fields that provide the values displayed in the list box.
- Click Select XPath to the right of the Value box, and select the field that contains the values stored in the form when a user clicks an item in the list box.
- Click Select XPath to the right of the Display name box, and select the field that contains the values displayed in the list box.
Insert a list box that looks up values from a Web service
- In design mode, place the insertion point where you want to insert the list box.
- If the Controls task pane is not visible, click More Controls on the Insert menu.
- In the Controls task pane, do one of the following:
- If you want Microsoft Office InfoPath 2003 to automatically create a field in the data source that is bound to the list box, make sure the Automatically create data source check box is selected.
- If you want to bind the list box to an existing field, make sure the Automatically create data source check box is cleared.
Note If the check box cannot be selected, the form's design does not allow the data source to be automatically created.
- Click List Box or Drop-Down List Box.
- If you cleared the Automatically create data source check box in step three, select a field to bind the list box to.
- Double-click the list box on the form.
- On the Data tab, click Look up in a database, Web service, or file, and then click Secondary Data Source.
- In the Secondary Data Sources dialog box, click Add.
- Follow the instructions in the Data Source Setup Wizard.
- Click Web service, and then click Next.
- On the second page of the wizard, type the location of the Web service, or click Search UDDI to search a UDDI server for a Web service.
- Select the Web service operation that will retrieve the data for your list box, and then click Next.
- For each of the parameters in the Parameters list, select the parameter, click Set Value, and then type the value you want the parameter to have. Then click Next.
- On the third page of the wizard, type a name for the Web service connection in the Enter a name for this data source box.
- If you want the form to always connect to the Web service when the form is opened, select the Connect to this secondary data source when the form is opened check box.
- Click Finish.
- In the Secondary Data Sources dialog box, click Close.
- The entries in the list box must be associated with a particular group in the XML Schema describing the Web service. Click Select XPath to the right of the Entries box, and select the repeating group that contains the fields that provide the values displayed in the list box.
- Click Select XPath to the right of the Value box, and select the field that contains the values stored in the form when a user clicks an item in the list box.
- Click Select XPath to the right of the Display name box, and select the field that contains the values displayed in the list box.
- The binding is correct.
- The control may not function as expected because of a potential binding problem. To identify the potential problem, right-click the control, and then click More Details on the shortcut menu.
- The control will not function correctly because of a binding problem. To identify the problem, right-click the control, and then click More Details on the shortcut menu.