Design a form connected to a database

Microsoft Office InfoPath

Show All Show All

Design a form connected to a database

When you design a new form that is connected to a database, Microsoft Office InfoPath 2003 builds a data structure for your form based on the tables and structure of the database. The resulting form can then be used to submit data to and query the database. You can work with the form in many of the same ways as when you design a new blank form— you can insert and lay out controls, add or remove data validation and conditional formatting, and publish the form.

Note  InfoPath can connect only to Microsoft SQL Server and Microsoft Access databases.

  1. On the File menu, click Design a Form.
  2. In the Design a Form task pane, click New from Data Source.
  3. On the first page of the Data Source Setup Wizard, click Database (Microsoft SQL Server or Microsoft Access only), and then click Next.
  4. On the second page of the Data Source Setup 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.

  5. If you want to add more than one table, do the following:
    • Click Add Table.
    • In the Add Table or Query dialog box, click the table you want to add, and then click Next.
    • In the Edit Relationship dialog box, make sure the connecting fields are correct. To add a set of connecting fields, click Add Relationship, select the two fields that are equal when a record in one table is associated with a record in another table, and then click OK.
    • In the Edit Relationship dialog box, click Finish.
  6. In the Data Source Setup Wizard, click Next.
  7. In the Summary box, make sure that the information matches the options you specified.
  8. At the end of the Wizard, InfoPath creates two views for your form: a query view, which already contains controls, and a data entry view, which is blank. To choose the view you want to design first, do one of the following:
    • To start by designing the query view, in which users can enter values with which to query the database, click Design query view first, and then click Finish.
    • To start by designing the data entry view, in which users can enter new records to submit to the database and edit existing records, click Design data view first, and then click Finish.
  9. To begin adding controls to the form, right-click a field or group in the Data Source task pane, and then, on the shortcut menu, click the control you want to insert. Use only query fields in the query view and only data fields in the data entry view.

Note  Because the data structure for the form must match the database, the following limitations apply:

  • You cannot automatically create the data source when inserting controls.
  • You cannot modify existing fields or groups in the data source.
  • You can only add fields or groups to the root group in the data source.