ACC2: Event Procedure Sets Incorrect Subform Field

ID: Q131882


The information in this article applies to:


SYMPTOMS

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

When you use an event procedure to set a value in a subform's recordset, Microsoft Access writes the value to the incorrect field. That is, it writes the value to a control bound to the field specified in the subform's LinkChildFields property rather than to the recordset field specified in the event procedure.


CAUSE

The subform does not have a control that is bound to the field that the event procedure sets.


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.


RESOLUTION

Add a control that is bound to the field that the event procedure sets to the subform.

If you do not want the control to be displayed, you can hide it using one of the following methods:


MORE INFORMATION

Steps to Reproduce Problem


  1. Open the sample database NWIND.MDB.


  2. Open the Orders Subform form in Design view.


  3. If the field list is not displayed, from the View menu, choose Field List. Drag the Order ID field from the field list to the subform's detail section.


  4. Delete the Product ID field from the Orders Subform form.


  5. Add an unbound combo box and set the control's properties as follows:
    
          Name: Product_Combo_Box
          RowSource: Products
          ColumnCount: 4
          ColumnWidths: 0 in; 0 in; 0 in; 1 in
          BoundColumn: 1 


  6. Set the combo box's AfterUpdate property to the following event procedure:
    
          Sub Product_Combo_Box_AfterUpdate ()
             Me![Product ID] = CLng(Me![Product_Combo_Box])
          End Sub 


  7. Save and close the Orders Subform form.


  8. Open the Orders form in Form view.


  9. Add a new record to the Orders Subform form by selecting a value from the Product_Combo_Box combo box. Note that Microsoft Access writes the value you select in the incorrect field. That is, the value appears in the Order ID field rather than in the Product ID field.



Keywords          : kbusage FmsSubf 
Version           : 2.0
Platform          : WINDOWS 
Issue type        : kbbug 

Last Reviewed: April 28, 1999