Microsoft KB Archive/282389

= ACC2002: Identity Increment Values Greater Than One Are Not Calculated Until the New Record Is Saved =

Article ID: 282389

Article Last Modified on 10/23/2003

-

APPLIES TO


 * Microsoft Access 2002 Standard Edition

-



This article was previously published under Q282389



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

This article applies only to a Microsoft Access project (.adp).



SYMPTOMS
When you add a new record to a Microsoft Access project (.adp) table, and the primary key identity column has an increment value of 2 or more, the value in the primary key column appears to be incremented only by 1 until you save the record. When you save or commit the record, the primary key column value is calculated correctly by using the increment that you specified in the Identity Increment property.



CAUSE
This behavior occurs because the value of the primary key column identity is not calculated until the AfterUpdate or AfterCommitTransaction events have occurred.



RESOLUTION
In the case where, in a second table, you are generating records that use the value of the identity column in the current new record, be sure that you force the current new record to be saved before you create the dependent record. Otherwise, the dependent record may use the incorrect identity column value, which results in a data-integrity problem.



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce the Problem
CAUTION: 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.

 Start Microsoft Access and open the sample project NorthwindCS.adp. In the Database window, under Objects, click Tables, and then click New.  Create the following table:   Column Name     Data Type     Length -    KeyID           int           4 Data           char          50  Select the KeyID column, and then, on the Columns tab, set the Identity property to Yes and the Identity Increment property to 2 .</li> On the Table Design toolbar, click Primary Key to make KeyID the primary key for the table.</li> On the File menu, click Save, name the table Table1, and then click OK.</li> On the View menu, click Datasheet View.</li> In the Data column, type Alpha, and then press TAB twice.

Notice that the first record is assigned a KeyID value of 1.</li> In the Data column of the next record, type Bravo.

Notice that the KeyID value for this record is only 2.</li> Press TAB and notice that the KeyID value for the second record is now 3, as expected.</li></ol>

Additional query words: pra

Keywords: kbbug kbpending KB282389

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.