Microsoft KB Archive/125593

= ACC2: Combo Box's AfterUpdate Event Fails =

Article ID: 125593

Article Last Modified on 11/6/2000

-

APPLIES TO


 * Microsoft Access 2.0 Standard Edition

-



This article was previously published under Q125593





SYMPTOMS
Moderate: Requires basic macro, coding, and interoperability skills.

If you choose a combo box's drop-down arrow, close the drop-down box without selecting an item, and then type an entry in the text portion of the combo box, the combo box's AfterUpdate event fails to update the information in the combo box.



CAUSE
The combo box's Column property is not updated if you enter a value in the combo box manually after choosing the drop-down arrow.



RESOLUTION
To work around this problem, requery the combo box as the first action in your event procedure or event macro. For example, given a combo box named MyCombo, you could requery the combo box with the following Access Basic statement:

  Me!MyCombo.requery



STATUS
Microsoft has confirmed this to be a problem in Microsoft Access version 2.0. This problem no longer occurs in Microsoft Access version 7.0.



MORE INFORMATION
A combo box's Column property is not updated if you type an entry in the combo box manually after choosing the combo box's drop-down arrow. If you are copying the value of the combo box's Column property to another control with the AfterUpdate event, you must requery the combo box as outlined in the "Resolution" section earlier in this article in order update the value of the Column property before you copy the value to another control.

Steps to Reproduce Problem
CAUTION: Following the steps in this example will modify the sample database NWIND.MDB. You may want to back up the NWIND.MDB file, or perform these steps on a copy of the NWIND database.

 Open the sample database NWIND.MDB. Open the Customer List query in Design view. Add the Contact Name field to the query's third column. Save and then close the query.  Open the Orders form in Design view. Change the Bill To combo box's properties as follows:

     ColumnCount: 3 ColumnWidths: 2;0;2 ListWidth: 4 in     AfterUpdate: [Event Procedure]   Choose the Build button to the right of the AfterUpdate property. Enter the following code in the form module that opens:

Sub_Customer_ID_AfterUpdate MsgBox Me![Customer ID].Column(2)

End Sub

Close the module. </li> View the form in Form view.</li> In the Bill To box, select Frankenversand. Note that a message box with the text "Peter Franken" appears. Choose OK.</li> In the Bill To box, type Godos and then press ENTER. Note that a message box with the text "Peter Franken" appears. The message box should display "Jose Pedro Freyre." Choose OK.</li></ol>

To correct this problem, add the following line to the combo box's AfterUpdate event procedure. Add this line before the MsgBox statement:

<pre class="fixed_text">  Me![Customer ID].Requery

Note that you can substitute the Recalc method for the Requery method. The Recalc method may provide better performance if you are not performing many floating-point operations. If you are performing many floating-point operations, the Requery method may provide better performance.

<div class="references_section">