Master/detail across views

Query and update records within a Microsoft Access database using master/detail functionality across two views in InfoPath 2003.

ADVERTISEMENTS

Problem

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.

Solution

Use master/detail functionality across views.

Discussion

You can accomplish master/detail functionality across views as follows:

  1. Create a Player table in a Microsoft Access database (Figure 1).
  2. Create a new InfoPath form: Use New from Data Connection... and bind it to the Player table.
  3. 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.
  4. Rename the default view to MasterView.
  5. Delete the New Record button and the query fields table on the master view.
  6. 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.
  7. Delete the ID, No, and Position columns from the repeating table.
  8. Add a column to the right of the Last Name column and add a button to this column.
  9. Modify the master view further to resemble the following figure:

    Figure 3. The master view in design mode.
  10. Create a new view and call it DetailsView
  11. 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
    The second rule should switch to the details view:
    Switch to view: DetailsView
  12. 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.
  13. 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.
  14. 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.

 
 Subscribe for updates via RSS or Email

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 of S.Y.M. Wong-A-Ton. 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, S.Y.M. Wong-A-Ton.

InfoPath 2013 Cookbook: 121 Codeless Recipes for Beginners
InfoPath 2013 Cookbook 2: 121 Codeless Recipes for SharePoint 2013
InfoPath 2010 Cookbook: 101 Codeless Recipes for Beginners
InfoPath 2010 Cookbook 2: 101 Codeless Recipes for SharePoint 2010
InfoPath 2010 Cookbook 3: 101 Code Recipes for C# Developers
InfoPath 2010 Cookbook 5: Integrating InfoPath with Excel and Excel Services


Related InfoPath Articles:

ADVERTISEMENTS

InfoPath 2013 Cookbook: 121 Codeless Recipes for Beginners

InfoPath 2013 Cookbook 2: 121 Codeless Recipes for SharePoint 2013

InfoPath 2010 Cookbook: 101 Codeless Recipes for Beginners

InfoPath 2010 Cookbook 2: 101 Codeless Recipes for SharePoint 2010

InfoPath 2010 Cookbook 3: 101 Code Recipes for C# Developers

InfoPath 2010 Cookbook 4: 101 Code Recipes for VB Developers

InfoPath 2010 Cookbook 5: Integrating InfoPath with Excel and Excel Services