Microsoft KB Archive/120971

{|
 * width="100%"|

PRB: "Can't Restore Field's Previous Value..." Error Message
'Article ID: Q120971

Creation Date: 23-SEP-1994

Revision Date: 01-DEC-1996' The information in this article applies to:


 * Microsoft Access versions 2.0, 7.0, 97

SYMPTOMS

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

In Microsoft Access 97 or 7.0, you receive the following error message:

The value in the field or record violates the validation rule for the record or field. In Microsoft Access version 2.0, you receive the following error message: Can't restore field's previous value; choose Undo Current Record or  Undo Current Field from the Edit menu. CAUSE

Visual Basic for Applications code canceled the BeforeUpdate event for a control in a record and Microsoft Access attempted to restore the field's original value. However, this value either violates a table-level validation rule or is a Null value in a field whose Required property is set to Yes.

RESOLUTION

There are two ways to work around this behavior:


 * Remove the table-level validation rule and set the field's Required property to No. Validate the data using validation rules at the form level, rather than at the table level.
 * Create a DefaultValue property setting for the field, so that the field always contains a valid value in a new record.

MORE INFORMATION

Steps to Reproduce Behavior

 Open the sample database Northwind.mdb (or NWIND.MDB in version 2.0)  Open the Orders table in Design view and set the following property for the ShipVia field. NOTE: In Microsoft Access 2.0, there is a space in the Ship Via field. "ValidationRule: >0" Save the table. When you see the prompt "Data integrity rules have been changed..." click Yes, and close the table. Open the Orders form in Design view.  Select the ShipVia option group (or Ship Via in version 2.0) and then set its BeforeUpdate property to the following event procedure: Sub ShipVia_BeforeUpdate(Cancel As Integer) ' Or Ship_Via_BeforeUpdate(Cancel as Integer) in version 2.0)            Cancel = True         End Sub  View the Orders form in Form view. On the Records menu, click Data Entry. Select any of the check boxes in the ShipVia (or Ship Via in version 2.0) option group. Note that you receive the error message mentioned in the "Symptoms" section.</li></ol>

This error occurs because the option group's BeforeUpdate event was canceled. In canceling the event, Microsoft Access attempted to restore the original value of the field. Because there is no default value for the field, Microsoft Access tried to insert a Null value in the field, but the Null value violated the table-level validation rule (>0). REFERENCES

For more information about table-level validation, search the Help Index for "validation," or ask the Microsoft Access 97 Office Assistant.

For more information about the Required property, search the Help Index for "Required property," or ask the Microsoft Access 97 Help Index.
 * }

-

"THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED 'AS IS' WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY." '' ©1997 Microsoft Corporation. All rights reserved. Legal Notices.

''

KBCategory: kbusage kberrmsg

KBSubcategory: FmsEvnt

Additional reference words: 2.00 7.00 97 8.00