Link a Form to a Database

InfoPath forms can submit data to Microsoft SQL or Microsoft Access databases. In fact, you can build forms directly from SQL and Access tables or queries. Working with existing data sources is where InfoPath forms really start to shine.

Tip

The following examples use the NWind.mdb Access database provided with the Office System 2003.

How to do it

The following procedure is for InfoPath SP1. The Version 1.0 release displays names in the task pane and produces a form containing separate query and data entry views. To build a form from a database table or query:

  1. Select File Design a Form. InfoPath displays the Design a Form task pane.

  2. Select New Data Connection. InfoPath starts the Data Source Setup Wizard.

  3. Select the Database option and click Next. The Wizard displays the next step.

  4. Click Select Database. The Wizard displays a list of the Office Data Connection (ODC) files found in the My Data Sources folder (Figure 7-16).

  5. Select a data connection or create a new ODC. The Wizard displays the tables and fields from the data connection (Figure 7-17).

  6. Select the fields to include or modify the SQL used to retrieve the data; then click Next. The Wizard displays the final step (Figure 7-18).

  7. Click Finish to generate the form template from the data connection (Figure 7-19).

Choose a data source

Figure 7-16. Choose a data source

Figure 7-17. Change the query as needed ...

Get Excel 2003 Programming: A Developer's Notebook now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.