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 2003 Service Pack 1 (870843)



The information in this article applies to:

  • Microsoft Office InfoPath 2003, Service Pack 1 (SP1)

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.

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:
  1. Start Microsoft Office InfoPath 2003 Service Pack 1.
  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

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 2003 Service Pack 1.
  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. Click Insert, and then 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, 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.
  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, 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.
  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.
  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.
  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.

Modification Type:MajorLast Reviewed:12/1/2004
Keywords:kbXML kbtshoot kbprb KB870843 kbAudDeveloper kbAudEndUser