Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

The filter may filter data in the first item of the repeating section or in the first item of the repeating table instead of in the current item in InfoPath


View products that this article applies to.

Symptoms

You can use a filter on a control in a repeating section or in a repeating table. However, the filter may filter data that is based on data in the first item of the repeating section or in the first item of the repeating table instead of in the current item.

↑ Back to the top


Resolution

If the control is in the context of the repeating container, replace the part of XPath for the filter that matches the binding of the repeating container with the current() property. For example, to use the current() property, replace the part of XPath in the "Steps to reproduce the problem" section. To do this, follow these steps

InfoPath 2003

  1. Start Microsoft Office InfoPath.
  2. Open your template.
  3. Right-click the second list box, and then click List Box Properties.
  4. In the List Box Properties dialog box, click Select XPath under Entries.
  5. Click Filter Data, and then click Modify.
  6. In the Specify Filter Conditions dialog box, click Use a formula in the third list box.
  7. In the Insert Formula dialog box, click to select the Edit XPath (advanced) check box.
  8. In the Formula box, type the following:

    current()/yourfield

InfoPath 2007

  1. Start Microsoft Office InfoPath.
  2. Open your template.
  3. Right-click the second list box, and then click Drop-Down List Box Properties.
  4. In the Drop-Down List Box Properties dialog box, click Select XPath to the right of the Entries field.
  5. Click Filter Data, and then click Modify.
  6. In the Specify Filter Conditions dialog box, click Use a formula in the third list box.
  7. In the Insert Formula dialog box, click to select the Edit XPath (advanced) check box.
  8. In the Formula box, type the following text:
    current()/yourfield

↑ Back to the top


More information

Steps to reproduce the problem

  1. Create a Products.xml file. To do this, follow these steps:
    1. Click Start, click Run, type Notepad, and then click OK.
    2. Copy the following code example to Notepad.
    <?xml version="1.0" encoding="utf-8" ?>
    <companies>
    	<company companyName="Tailspin Toys">
    		<product name="Duckie" />
    		<product name="Doggie" />
    	</company>
    	<company companyName="Wingtip Toys">
    		<product name="Jammin Joker" />
    		<product name="Qwik Queenie" />
    	</company>
    	<company companyName="Microsoft">
    		<product name="Windows XP" />
    		<product name="Windows 2000" />
    		<product name="Office 2003"  />	
    	</company>
    </companies>
    
    Save the file. Name the file Products.xml.
  2. Start InfoPath.
  3. Design a new form.
  4. Click Tools, click Data Connections, and then click Add.
  5. Click Receive data, click Next, and then click XML document.
  6. Click Next, click the Products.xml file that you created in step 1, click Next, and then click Finish.
  7. If you receive the following message, click No:
    The selected file is not part of the form, which means it might not be accessible from other computers. Do you want to add this file to your form so that it will be accessible from other computers?
  8. In the Data Connections dialog box, click Close.
  9. On the Insert menu, click More Controls.
  10. In the Insert Controls dialog box, click Repeating Section under Repeating and Optional.
  11. Click inside the section that is mentioned in step 10 to put the pointer in the section.
  12. In the Insert Controls dialog box, click List Box two times.

    List Box is under Standard.

    Note Two list boxes are inserted in the repeating section.
  13. Right-click the first list box, and then click List Box Properties.
  14. In the List Box Properties dialog box in InfoPath 2003, click Look up values in a data connection to a database, Web service, file, or SharePoint library or list on the Data tab under List box entries.

    In the List Box Properties dialog box in InfoPath 2007, click Look up values in the form's data source under List box entries.
  15. Under Entries, click Select XPath.
  16. In the Select a Field or Group dialog box, expand companies, click company, and then click OK.
  17. Right-click the second list box, and then click List Box Properties.
  18. In the List Box Properties dialog box in InfoPath 2003, click Look up values in a data connection to a database, Web service, file, or SharePoint library or list on the Data tab under List box entries.

    In the List Box Properties dialog box in InfoPath 2007, click Look up values in the form's data source under List box entries.
  19. Under Entries, click Select XPath.
  20. In the Select a Field or Group dialog box, expand companies, and then click company.
  21. In the Filter Data dialog box, click Filter Data. In the Specify Filter Conditions dialog box, click Add in the first list box, click companyName in the second list box, and then click is equal to in the third list box. Click Select a Field or Group.
  22. In the Select a Field or Group dialog box, click Main under Data source. Expand group1, expand group2, click field1, and then click OK.
  23. In the Filter Data dialog box, click OK.
  24. In the Select a Field or Group dialog box, click OK.
  25. Under Value, click Select XPath, expand company, expand product, click name, and then click OK.
  26. Under Display name, click Select XPath, expand company, expand product, click name, and then click OK.
  27. Click OK.
  28. On the InfoPath 2003 toolbar, click Preview Form.

    On the InfoPath 2007 toolbar, click Preview, and then click Form.
  29. In the first list box, click Tailspin Toys.
  30. Right-click the repeating section, and then click Insert group below.
  31. In the second repeating section, click Microsoft in the first list box.

    Note You can see the products for both companies.

Steps to resolve this problem

  1. Click Close Preview.
  2. Right-click the second list box, and then click List Box Properties.
  3. Under Entries, click Select XPath.
  4. In the Select a Field or Group dialog box, click Filter Data, click Modify, click the third list box, and then click Use a formula.
  5. In the Insert Formula dialog box, click to select the Edit XPath (advanced) check box.
  6. In the Formula box, type current()/my:field1, and then click OK.

    Note This step uses the current() property to replace the part of XPath that refers to the binding of the repeating section. You want to use the current() property so that the filter can keep the current context. In this case, the part of XPath is as follows:

    xdXDocument:get-Dom()/my:myFields/my:group1/my:group2
  7. In the Specify Filter Conditions dialog box, click OK.
  8. In the Filter Data dialog box, click OK.
  9. In the Select a Field or Group dialog box, click OK.
  10. In the List Box Properties dialog box, click Select XPath under Value.
  11. In the Select a Field or Group dialog box, expand product, click name, and then click OK.
  12. In the List Box Properties dialog box, click Select XPath under Display name.
  13. In the Select a Field or Group dialog box, expand product, click name, and then click OK.
  14. In the List Box Properties dialog box, click OK.
  15. On the InfoPath 2003 toolbar, click Preview Form.

    On the InfoPath 2007 toolbar, click Preview, and then click Form.
  16. Right-click the repeating section, and then click Insert group below.

    Note If you click a company in the top section, you can see the product of the company in the second list box.
  17. Click a different company in the second section.

    Note You can only see the products for the company that you selected in the first list box of the second section.

↑ Back to the top


Keywords: KB870843, kbprb, kbtshoot, kbxml

↑ Back to the top

Article Info
Article ID : 870843
Revision : 4
Created on : 1/30/2007
Published on : 1/30/2007
Exists online : False
Views : 485