To resolve this problem, you can use Data Definition Language (DDL) to create a table with an
Identity column that has the seed and the increment values that you want, other than the default value of one. Then, add the remaining fields
that you want in Design view.
The following steps show you how to do this:
- Open the sample database Northwind.mdb.
- On the Tools menu, click References.
- In the list of available References, click to select Microsoft ActiveX Data Objects 2.1 Library.
- Create a module, and then type the following line in the "Declarations"
section if it is not already there:
- Type the following procedure:
'This Example creates a table that is called tblEmployees with
'custom identity seed values.
Function CreateNewTable(tName As String, colName As String, _
vSeed As Integer, vInc As Integer)
Dim conn As ADODB.Connection
Set conn = CurrentProject.Connection
conn.Execute "Create Table " & tName & "(" & colName & _
" Identity(" & vSeed & ", " & vInc & "));"
Application.RefreshDatabaseWindow
End Function
- Type the following line in the Immediate window, and then press ENTER:
?CreateNewTable("tblEmployees", "EmpID", 1000, 5)
Note that a new table that is named tblEmployees appears in the Database window. The table, tblEmployees, has one column called EmpID that is an IDENTITY property with a seed of 1000 and an increment of five.
- Open tblEmployees in Design view, and then add any other columns to the new table that you have to.
NOTE: You must add at least one column to complete the
next step.
- Switch to Datasheet view, and then add a few new records. Note the
EmpID for the first record is 1000, the second is 1005, and so on.
NOTE: When you copy, export, import, transfer tables into a new table or database, or delete all records in the table and compact the database, the
IDENTITY property seed or the increment values, or both, are set back to the default of 1.
For additional information, click the article number below
to view the article in the Microsoft Knowledge Base:
202117 ACC2000: Jet IDENTITY Datatype Seed and Increment Reset to 1