Microsoft KB Archive/931409

= The resulting value is incorrect if you use the count function to count the number of selected items in a multiple selection list box control in InfoPath 2007 =

Article ID: 931409

Article Last Modified on 2/8/2007

-

APPLIES TO


 * Microsoft Office InfoPath 2007

-



SYMPTOMS
In Microsoft Office InfoPath 2007, the count function may return an incorrect value for the number of items that a user has selected. Consider the following scenario:
 * You have an InfoPath 2007 form that contains a multiple-selection list box control.
 * You use an external secondary data source for the items in the multiple-selection list box control.
 * You use the count function to determine how many items a user has selected in the multiple-selection list box control.

In this scenario, the count function returns an incorrect value. The value is one item more than the number of items that the user has selected.



CAUSE
This issue occurs because a multiple-selection list box control that uses an external data source for its values will have a blank entry in the list. This is the default behavior.



WORKAROUND
To work around this issue, use one of the following methods.

Method 1 Remove the default value for the multiple selection list box control. To do this, follow these steps:
 * 1) Click Default Values on the Tools menu.
 * 2) Click to clear the check box of the repeating field to which the multiple selection list box is bound.
 * 3) Click OK.

Method 2 Count only nonblank items from the multiple-selection list box control. To do this, use an expression that resembles the following: count(my:group1/my:field1[text != &quot;&quot;]) Method 3 Subtract one item from the count result. To do this, use an expression that resembles the following: count(my:group1/my:field1) - 1



STATUS
This behavior is by design.

Additional query words: IP2007 InfoPath2007

Keywords: kbexpertiseinter kbtshoot kbprb KB931409

-

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

© Microsoft Corporation. All rights reserved.