7.2. Utilizing Command Buttons

Command buttons, or buttons for short, are the way you can tell the form to perform various tasks you want to perform. You have already seen a couple of examples of buttons in looking at the Run Query and New Record buttons created by InfoPath.

To add a command button to the form, click on the Controls task in the Design Tasks task pane, and then click a Button, dragging it to the spot you want it located. Once it is on there you can open the property sheet. The first page of the property sheet is a General tab, and on it you can specify the Action you want the button to perform. If you want to have InfoPath perform a task for you from the Action field, you can choose from the following list:

  • Run Query: Queries the database, populating fields specified as data fields.

  • Submit: Saves changes to the database.

  • New Record: Creates a new blank form to be filled out.

  • Delete & Submit: Deletes the current record and saves the change to the data source.

  • Rules & Custom Code: When the four preceding tasks don't do the trick, you can use this task to either create a rule or use custom code to perform your task. This option is discussed in greater detail in Chapter 11, "Working with Code in Your InfoPath Form."

When you specify an Action that includes submitting the form to the database, the Submitting Forms dialog box will appear, enabling you to set up various properties. This dialog box is displayed in Figure 7-6.

The Submitting Forms dialog box is very powerful ...

Get Beginning InfoPath™ 2003 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.