Microsoft KB Archive/870843

= 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 =

Article ID: 870843

Article Last Modified on 1/30/2007

-

APPLIES TO


 * Microsoft Office InfoPath 2007
 * 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 &quot;Steps to reproduce the problem&quot; 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/

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

current/

</li></ol>

<div class="moreinformation_section">

Steps to reproduce the problem
<ol>  Create a Products.xml file. To do this, follow these steps: <ol style="list-style-type: lower-alpha;"> Click Start, click Run, type Notepad, and then click OK.</li> Copy the following code example to Notepad.</li></ol>

<?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?> <company companyName=&quot;Tailspin Toys&quot;> <product name=&quot;Duckie&quot; /> <product name=&quot;Doggie&quot; /> <company companyName=&quot;Wingtip Toys&quot;> <product name=&quot;Jammin Joker&quot; /> <product name=&quot;Qwik Queenie&quot; /> <company companyName=&quot;Microsoft&quot;> <product name=&quot;Windows XP&quot; /> <product name=&quot;Windows 2000&quot; /> <product name=&quot;Office 2003&quot; /> Save the file. Name the file Products.xml. </li> Start InfoPath.</li> Design a new form.</li> Click Tools, click Data Connections, and then click Add.</li> Click Receive data, click Next, and then click XML document.</li> Click Next, click the Products.xml file that you created in step 1, click Next, and then click Finish.</li> 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?

</li> In the Data Connections dialog box, click Close.</li> On the Insert menu, click More Controls.</li> In the Insert Controls dialog box, click Repeating Section under Repeating and Optional.</li> Click inside the section that is mentioned in step 10 to put the pointer in the section.</li> 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.</li> <li>Right-click the first list box, and then click List Box Properties.</li> <li>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.</li> <li>Under Entries, click Select XPath.</li> <li>In the Select a Field or Group dialog box, expand companies, click company, and then click OK.</li> <li>Right-click the second list box, and then click List Box Properties.</li> <li>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.</li> <li>Under Entries, click Select XPath.</li> <li>In the Select a Field or Group dialog box, expand companies, and then click company.</li> <li>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.</li> <li>In the Select a Field or Group dialog box, click Main under Data source. Expand group1, expand group2, click field1, and then click OK.</li> <li>In the Filter Data dialog box, click OK.</li> <li>In the Select a Field or Group dialog box, click OK.</li> <li>Under Value, click Select XPath, expand company, expand product, click name, and then click OK.</li> <li>Under Display name, click Select XPath, expand company, expand product, click name, and then click OK.</li> <li>Click OK.</li> <li>On the InfoPath 2003 toolbar, click Preview Form.

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

Note You can see the products for both companies.</li></ol>

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
 * 1) In the Specify Filter Conditions dialog box, click OK.
 * 2) In the Filter Data dialog box, click OK.
 * 3) In the Select a Field or Group dialog box, click OK.
 * 4) In the List Box Properties dialog box, click Select XPath under Value.
 * 5) In the Select a Field or Group dialog box, expand product, click name, and then click OK.
 * 6) In the List Box Properties dialog box, click Select XPath under Display name.
 * 7) In the Select a Field or Group dialog box, expand product, click name, and then click OK.
 * 8) In the List Box Properties dialog box, click OK.
 * 9) On the InfoPath 2003 toolbar, click Preview Form.

On the InfoPath 2007 toolbar, click Preview, and then click Form.
 * 1) 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.
 * 1) 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.

Additional query words: IP2007

Keywords: kbxml kbtshoot kbprb KB870843

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.