Home > Articles > Web Services > XML

  • Print
  • + Share This
From the author of

Creating an InfoPath Form

Now that I've described the components that make up an InfoPath form, let's look at one of several techniques that can be used to design a simple InfoPath form. In this example, we'll create a simple form that's connected to the Northwind sample database supplied with InfoPath. InfoPath provides several ways to accomplish each task. The instructions given here are based on the final version of InfoPath 2003.

  1. Open InfoPath and the task pane, if necessary.

  2. TIP

    Press Ctrl+F1 to open the task pane.

  3. Select the Design a Form option from the drop-down list.

  4. In the Design a Form task pane, choose the New from Data Source option (see Figure 2). This step opens the Data Source Setup Wizard.

  5. Figure 2Figure 2 Designing a new form from a data source.

  6. Select the Database option and click Next.

  7. On the next screen, click the Select Database button and navigate to the Northwind sample database. For example, the relevant version of the Northwind database is located at the following path on my machine:

  8. C:\Program Files\Microsoft Office 2003\OFFICE11\SAMPLES\NORTHWIND.mdb
  9. After selecting the database, select the table(s) to use in the form. For this simple example, scroll down to the Suppliers table and select it.

  10. In the next dialog box, deselect all columns except CompanyName, ContactName, and ContactTitle. You have options to add further tables, but for this example we'll just click Next (see Figure 3).

  11. Figure 3Figure 3 Fields in the Access Suppliers table.

  12. You have the option to design the query view or data view first. Select Query View and click Finish. A simple query view is created automatically; this view is functionally able to query the Access database (see Figure 4). However, we don't yet have a view to display the data returned by the query.

  13. Figure 4Figure 4 The query view that InfoPath creates automatically.

  14. If the task pane isn't visible, press Ctrl+F1 to display it. From the task pane drop-down list, select the Views task pane. The pane shows that two views exist (see Figure 5): the query view that we've just seen, and the data entry view. Click the Data Entry option to switch to that view. The view is blank.

  15. Figure 5Figure 5 The Views task pane.

  16. To create a basic data entry view, click Data Source on the task pane. This step switches to the data source task pane. Drag the CompanyName node to the form area. A repeating section is created, with a text box (intelligently named Company Name) inserted automatically. Drag the ContactName and ContactTitle nodes (from the dataFields) inside the repeating section. Named text boxes are created automatically for these features. InfoPath intelligently handles the field names so that they appear as discrete words on the view (see Figure 6).

  17. Figure 6Figure 6 Form with text boxes added.

  18. Click Controls in the Data Source task pane to open the Controls task pane. Drag a button control to the form area, making sure that it's not inside the repeating section.

  19. Right-click the Button control and select Button Properties.

  20. On the General tab of the dialog box, select Submit from the Action drop-down list, and alter the label to read Submit (see Figure 7).

  21. Figure 7Figure 7 Altering button properties.

  22. Accept the defaults in the next dialog box that opens; then click OK to accept the changes to the Button control's properties.

  23. Now we can test the form. Click the Preview Form button on the toolbar, or press Alt+P. Switch to the Query view by choosing View, Query from the menu. Enter the text Exotic Liquids in the CompanyName text box and click the Run Query button. (Exotic Liquids is a company listed in the Northwind database.) The Data Entry view opens with the relevant contact information fields for Exotic Liquids containing the requested data (see Figure 8).

  24. Figure 8Figure 8 Data returned from the query.

    That's all there is to creating a very basic but functional InfoPath form. Of course, you can do much more to improve form layout, add validation that goes beyond what the W3C XML Schema can provide, and script custom functionality. But end users can create simple but functional forms like this very quickly.


    As mentioned earlier, serious use of InfoPath 2003 requires knowledge of XML and JScript or VBScript. Understanding of W3C XML Schema, XSLT, the XML DOM, and XPath will also be very useful to InfoPath developers.

  • + Share This
  • 🔖 Save To Your Account