Microsoft KB Archive/207684

= ACC2000: Error Updating Field When Adding New Record to Form =

Article ID: 207684

Article Last Modified on 6/24/2004

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q207684



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

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).

For a Microsoft Access 2002 version of this article, see 289659.



SYMPTOMS
When you type data into a new record on a form that is based on a query or an SQL statement, you receive one of the following error messages:

Field cannot be updated.

or

Multiple-step operation generated errors. Check each status value.

When you click OK, you can continue editing and then save the record.



CAUSE
This behavior occurs when you try to update a read-only field in a record by using either the DefaultValue property or Visual Basic for Applications.



RESOLUTION
Do not use the DefaultValue property or Visual Basic for Applications to edit read-only controls.



MORE INFORMATION
When you create a form based on a query, any control bound to a query field containing an expression is read-only. Because the query expression is not bound to any specific field in the underlying table, you cannot edit the values in these fields. However, when you set the DefaultValue property of such a control, Access attempts to write a new value to that control every time you add a new record.

Steps to Reproduce Behavior
CAUTION: If you follow the steps in this example, you modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and follow these steps on a copy of the database.


 * 1) Start Microsoft Access, and then open the sample database Northwind.mdb or the sample project NorthwindCS.adp.
 * 2) Open the Orders Subform form in Design view.
 * 3) Select the Extended Price text box; on the View menu, click Properties, and then set the DefaultValue property to 0 (zero).
 * 4) Close and save the Orders Subform form.
 * 5) Open the Orders form, and then add a new item to any order. Note that you receive one of the error messages described in the "Symptoms" section.

