Master/detail across views
Query and update records within a Microsoft Access database using master/detail functionality across two views in InfoPath 2003.
You want to display a list of all the records in a database table, click on a record in the list, and then open another screen to edit this record.
Use master/detail functionality across views.
You can accomplish master/detail functionality across views as follows:
- Create a Player table in a Microsoft Access database (Figure 1).
- Create a new InfoPath form: Use New from Data Connection... and bind it to the Player table.
- Add a field called HelperField of the same type as the ID field in
your database table, i.e. Whole Number (integer), to the Main data source of the form.
Our Main data source should now resemble the following figure:
Figure 2. Main data source of the InfoPath form.
- Rename the default view to MasterView.
- Delete the New Record button and the query fields table on the master view.
- Drag the Player repeating group from the dataFields node in the Main data source to the data fields table section on the master view; use a Repeating Table to display the records.
- Delete the ID, No, and Position columns from the repeating table.
- Add a column to the right of the Last Name column and add a button to this column.
- Modify the master view further to resemble the following figure:
Figure 3. The master view in design mode.
- Create a new view and call it DetailsView
- Create two rules on the button in the repeating table on the master view:
The first rule should set the value of the HelperField to the ID of the record that is selected in the repeating table:
Set a field's value: HelperField = current()/@ID
Switch to view: DetailsView
- Drag the Player repeating group from the dataFields node in the Main data source and drop it on the Details View; use a Repeating Section to display the records.
- Modify the details view to resemble the following figure:
Figure 4. The details view in design mode.
The Back to Master View button should contain a rule to switch back to the master view.
- Since you want to only display the details of the selected player from the master view,
you need to filter the data being shown by the repeating section on the details view as follows:
Double-click on the repeating section to open its Properties dialog box.
Click on the Display tab.
Click on the Filter Data... button. Add a Condition that says:
ID = HelperField
Your master/detail across views should now be functioning properly.
Related InfoPath Articles:
- InfoPath 2010 master detail example
- Database record selection in InfoPath through a dropdown list box
- Sequential database table record navigation
- Connect InfoPath master detail to SQL Server Express
- InfoPath 2010 switch views with tabs
Copyright: This article may not be used on web sites (whether personal or otherwise), copied, disseminated, altered, printed, published, broadcasted, or reproduced in any way without an expressed written consent. The techniques demonstrated in this article may be used within any Microsoft InfoPath project. This article is provided without any warranties. Copyright for this article is non-transferrable and remains with the author.