Microsoft KB Archive/95450

= ACC: Cannot Change Combo Box Value If ControlSource Property Is Set to AutoNumber Field =

Article ID: 95450

Article Last Modified on 1/18/2007

-

APPLIES TO


 * Microsoft Access 1.0 Standard Edition
 * Microsoft Access 1.1 Standard Edition
 * Microsoft Access 2.0 Standard Edition
 * Microsoft Access 95 Standard Edition
 * Microsoft Access 97 Standard Edition

-



This article was previously published under Q95450



Novice: Requires knowledge of the user interface on single-user computers.



SYMPTOMS
If the ControlSource property of a combo box is set to a field that has an AutoNumber data type (or Counter in versions 1.x and 2.0), when you try to change the value in the combo box, you receive the following message on the status bar:

In Microsoft Access 7.0 and 97

  Control can't be edited; it's bound to AutoNumber field .

In Microsoft Access 1.x and 2.0

  Control can't be edited; it's bound to Counter field.



CAUSE
The control source of a combo box is a table field where Microsoft Access writes your combo box selection. By design, modifications to an AutoNumber field are not allowed. Therefore, if the ControlSource property of a combo box is set to an AutoNumber field, Microsoft Access cannot update the value in the AutoNumber field; therefore, you cannot change the combo box value. Microsoft Access gives you the message to tell you why it cannot update the combo box control.



RESOLUTION
Either change the data type of the field in the ControlSource property of the combo box, or set the ControlSource property to a field that does not have an AutoNumber (or Counter) data type.



Steps to Reproduce Behavior
 Start Microsoft Access, and open the sample database Northwind.mdb (or NWIND.MDB in Microsoft Access 2.0 or earlier).  Create a new table called MyTest:

     Table: MyTest Field Name: MyAutoNumber Data Type: AutoNumber (or Counter in Microsoft Access 1.x and 2.0) Field Name: MyData Data Type: Number Field Name: MyBucket Date Type: Number  Open the MyTest table in Datasheet view and enter a few records by typing numeric values in the MyData field. Note that Microsoft Access automatically fills in the MyAutoNumber field and puts zeroes in the MyBucket field as you type values in the MyData field.</li> Create a new blank form in Design view based on the MyTest table.</li>  Add a combo box to the form and set the following properties:

<pre class="fixed_text">     Combo Box: ControlSource: MyAutoNumber RowSource: MyTest </li> Switch the form to Form view. Note that the combo box values are the sequential numbers coming from the MyAutoNumber field.</li> In the combo box list, try to select a new value. Note that you receive the error message on the status bar, and the value in the combo box does not change.</li> Switch back to Design view and change the combo box ControlSource property from MyAutoNumber to MyBucket.</li> Switch back to Form view and repeat step 7. Note that now you can select items from the combo box. If you look at the contents of the table, you can see that the values you selected were written to the MyBucket field.</li></ol>

<div class="references_section">