When using InfoPath as a front end to a large database it is often convenient to be able to skim through the rows looking at only a few columns, such as a contact name, and then click a button to view the rest of the information.
You can use an InfoPath data filter to easily and quickly implement this functionality. However, this method might not be ideal for very large databases as its performance could suffer. If you are connecting to a very large database, and performance is important, please see Create a Multi-View Master/Detail using a Query Filter.
In this task we will create a new form connected to a sample Access database and use controls, rules, and filters to create a multi-view master/detail list.
Obtaining the sample Access database:
The sample Access database we will use is supplied as part of the Microsoft Office 2003 default installation. If installed, you can locate it at C:\Program Files\Microsoft Office\OFFICE11\SAMPLES\Nwind.mdb. If the database file does not exist in this directory, you can download it from the Microsoft Web site at http://www.infopathdev.com/cgi-bin/awredir.pl?url=http://www.microsoft.com/downloads/details.aspx?FamilyID=C6661372-8DBE-422B-8676-C632D66C529C&displaylang=en.
Create a new form from a database connection:
- Launch InfoPath, and then choose Design A Form from the File menu.
- In the Design A Form task pane, click New From Data Connection.
- In the Data Connection Wizard, select Database, and then click Next.
- Click Select Database, locate and select Nwind.mdb, and then click Open.
- In the Select Table dialog box, select the Customers table, and then click OK.
- Click Next, and then click Finish.
- Delete everything that was automatically generated in the view except for the Run Query button (we will keep this at the top of the page).
- Click below the Run Query button to set the insertion point.
Create the master view:
- Open the Data Source task pane.
- Right-click dataFields/d:Customers, and then choose Repeating Table.
- Delete every column in the table except for Contact Name.
- Right-click the Contact Name column label, and then choose Insert | Columns To The Right.
- Click inside the new column to set the insertion point.
- Open the Controls task pane, and then click Button.
- Double-click the inserted button.
- In the Button Properties dialog box, change the label to View Detail, change the ID to btnViewDetail, and then click OK (see Figure 1).

Figure 1. The completed master view.
Create the detail view:
- Open the Views task pane.
- Click Add A New View.
- Name the view Detail, and then click OK.
- Open the Data Source task pane.
- Right-click dataFields/d:Customers, and then choose Repeating Section With Controls (see Figure 2).

Figure 2. The completed detail view.
We need to add a helper node to the schema to store the ID of the customer selected in the master view. This ID will be used to filter the display in the detail view to show only the selected customer. After setting this value, we will switch to the detail view.
Add the helper node:
- In the Data Source task pane, right-click myFields, and then choose Add.
- Name the field DetailId.
- Select Whole Number from the Data Type drop-down list.
- Click OK.
Add rules to the View Detail button:
- Open the Views task pane, and then select View 1.
- Double-click the View Detail button.
- In the Button Properties dialog box, click Rules, and then click Add.
- Name the rule Update DetailId and Change Views.
- Click Add Action.
- Choose Set A Field’s Value from the Action drop-down list.
- Click the Data Source button to the right of the Field text box.
- In the Select A Field Or Group dialog box, select my:DetailId, and then click OK.
- Click the Insert Formula button to the right of the Value text box.
- In the Insert Formula dialog box, click Insert Field Or Group.
- Select dataFields/d:Customers/:CustomerID, and then click OK three times.
- In the Rule dialog box, click Add Action.
- Choose Switch Views from the Action drop-down list.
- Choose Detail from the View drop-down list, and then click OK (see Figure 3).
- Click OK three times to close all open dialog boxes.

Figure 3. Adding rules to the View Detail button.
The functionality has been added to the button, but the detail view still displays all of the rows. Let's add a filter to repeating section in the detail view to show only the selected row.
Add a filter to the detail section:
- In the Views task pane, select Detail.
- Double-click the repeating section label.
- On the Display Tab, click Filter Data, and then click Add.
- In the Specify Filter Conditions dialog box, select CustomerID from the first drop-down list.
- In the second drop-down list, select Is Equal To.
- In the third drop-down list, select Select A Field Or Group.
- In the Select A Field Or Group dialog box, choose my:DetailId, and then click OK (see Figure 4).
- Click OK three times to close all open dialog boxes.

Figure 4. Filter the detail view based on the selected Customer ID.
Try it:
- Click Preview Form (or press Alt+P on the keyboard).
- Click Run Query to populate the master table.
- Click View Detail for one of the rows to view the selected contact in the detail view.