Article ID: 275090 - Last Review: November 5, 2003 - Revision: 3.1 ACC2002: @@IDENTITY Returns Incorrect Identity Column Value
This article was previously published under Q275090 Advanced: Requires expert coding, interoperability, and multiuser skills.
This article applies only to a Microsoft Access project (.adp). On This PageSYMPTOMS
When you enter new data into a Microsoft Access database, your entry is immediately replaced by incorrect values. -or- When you enter new data, you receive the following error message:
The data was added to the database but the data won't be displayed in the form because it doesn't satisfy the criteria in the underlying record source.
CAUSE
This behavior occurs because the @@IDENTITY function is used to resynchronize data after new records are added. This function returns the last identity column value created in the current session. When you add a new record, the Cursor Engine uses the @@IDENTITY function to resynchronize all records and ensure that all data is available.
RESOLUTION
To work around this issue, use one of the following methods.
Manually Refresh the RecordsTo view the data that you have just entered, click Refresh on the Records menu. By doing so, you update your display with the most current data.Automatically Refresh the RecordsAlternatively, you can use a form to add records and use the form's AfterInsert event to refresh the form. By doing so, the cursor is repositioned on the first record after the record is added. You can use the GoToRecord method to move to a new record.
STATUSMicrosoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. MORE INFORMATION
If the current session adds records to other tables, for example, by using a trigger, the @@IDENTITY function may return the value inserted into the other table and therefore display incorrect records for the current table.
Steps to Reproduce the ProblemCAUTION: If you follow the steps in this example, you modify the sample Access project NorthwindCS.adp. You may want to back up the NorthwindCS.adp file and follow these steps on a copy of the project.
Note that this issue affects only the way data is displayed and has no bearing on the integrity of the data stored in the underlying table. REFERENCES
For more information about the @@IDENTITY function, see SQL Server Books Online at the following MSDN Web site:
http://msdn.microsoft.com/en-us/library/aa237426.aspx
(http://msdn.microsoft.com/en-us/library/aa237426.aspx)
| Other Resources Other Support Sites
CommunityGet Help NowArticle Translations
|






Windows Live
Facebook
Twitter
Linkedin
Digg it
Yahoo
Delicious
StumbleUpon
Yammer
Reddit
Technorati
FriendFeed
Email
Back to the top
