Microsoft KB Archive/123653

= ACC: Error Message Adding Record to Subform =

Article ID: 123653

Article Last Modified on 1/19/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 Q123653



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



SYMPTOMS
When you try to add a new record to a subform, you receive the following error message:

In Microsoft Access 97:

An error occurred while referencing the object. You tried to run a Visual Basic procedure that improperly references a property or method of an object.

In Microsoft Access 7.0:

An error occurred while referencing the OLE Automation object. You tried to run a Visual Basic procedure that improperly references a property or method of an OLE Automation object.

In Microsoft Access 1.x or 2.0:

Can't set value.



CAUSE
This error can occur if the subform's LinkChildFields property contains the name of a form property.



RESOLUTION
Change the name contained in the subform's LinkChildFields property and the name of the associated field in the underlying table to something other than the name of a form property.



MORE INFORMATION
When you add a record to a linked subform, Microsoft Access sets the value from the field on the main form specified in the subform's LinkMasterFields property to the field on the subform specified in the subform's LinkChildFields property. If the field specified in the LinkChildFields property is the name of a form property, Microsoft Access tries to set the value of that property for the form instead of the field. Note that this behavior is normal, and the values will therefore update normally after displaying the error.

Steps to Reproduce Behavior
 Start Microsoft Access and create a new database.  Create the following two tables:

     Table Name: OneSideTable Field Name: AName Data Type: Text

Set the AName field as the primary key for the OneSideTable table.

Table Name: ManySideTable -     Field Name: Num Data Type: Number Field Name: Parent Data Type: Text

Note that Parent is the name of a form property.  Create a one-to-many relationship between the OneSideTable table and the ManySideTable table using the OneSideTable table as the primary table. Join the AName field with the Parent field to create the relationship. Enforce referential integrity. Use the Form Wizard to create a main form and subform. Use the OneSideTable table for the main form, and the ManySideTable table for the subform. Open the main form in Form view and then try to add a record to the subform. You receive the error message stated above. Once you click OK you can add the new record.</li></ol>

<div class="references_section">