ACC: List Box Column Property Gets Incorrect Row InformationLast reviewed: May 28, 1997Article ID: Q109827 |
The information in this article applies to:
SYMPTOMSModerate: Requires basic macro, coding, and interoperability skills. When you select a row from a multicolumn list box or combo box, controls that reference the Column property of the list box or combo box retrieve data from a different row in the list box or combo box. NOTE: A list box may appear to work as desired, but upon binding the list box, it will exhibit the same behavior as a combo box.
CAUSEThe list or combo box's BoundColumn property does not point to a field with unique values.
RESOLUTIONThe list or combo box's BoundColumn property must point to a field that contains unique values. If the BoundColumn property does not point to a field with unique values, Microsoft Access will return information for the first row with a matching BoundColumn value when you select a row in the list box or combo box. For example, the Type field in the sample table below does not contain unique values. If the Type field is used for the BoundColumn property, a text box referencing the second column will return Apple rather than Grape when you select the third row.
Type Description ------------------- Fruit Apple Fruit Orange Fruit GrapeIf you use the Description column for the BoundColumn property, the behavior will not occur because the Description column contains unique values. Another way to resolve this behavior would be to add a Counter field (or AutoNumber field in Microsoft Access 7.0 and 97) to the underlying table, and then use the Counter field (or AutoNumber field)for the BoundColumn property. In Microsoft Access 7.0 and 97, the following code can be added to the AfterUpdate property of the combo box.
Me![Stock Number] = _ Me![Manufacturer].Column(1, Me![Manufacturer].ListIndex) Me![Description] = _ Me![Manufacturer].Column(2, Me![Manufacturer].ListIndex) NOTE: If you use this code, remove the expressions that are assigned to the ControlSource properties of the Stock Number control and Description control.In Microsoft Access 7.0 and 97, the ListIndex property of the combo box or list box can be used as a pointer to the correct row in the combo box or list box. Non-unique columns in a combo box or list box can be resolved by setting the BoundColumn property to 0 (zero). This will allow a text box on a form to be populated with, for example, a value in combox.column(1) when no columns with the combo box contain unique values.
MORE INFORMATION
Steps to Reproduce Behavior
REFERENCESFor more information about creating combo boxes, search the Help Index for "creating combo boxes," or ask the Microsoft Access 97 Office Assistant.
|
Additional query words: duplicate bound column
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |