ACC2000: Can't Change Default Seed and Increment Value in UIID: Q202121
|
In Microsoft Access 2000, you can change the seed and increment value of an AutoNumber field, otherwise known as an Identity column, from the default value of one. However, there are no options available in the user interface (UI) for you to make this change.
Use Data Definition Language (DDL) to create a table with an
Identity column that has the seed and 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 demonstrate how to do this:
Option Explicit
'This Example creates a table 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
?CreateNewTable("tblEmployees", "EmpID", 1000, 5)
Note that a new table named tblEmployees appears in the Database window. The table, tblEmployees, has one column called EmpID, which is an IDENTITY property with a seed of 1000 and an increment of five.
Table: Table1
-------------------------------
Field Name: CategoryID
Data Type: AutoNumber
Indexed: Yes (No Duplicates)
Field Name: Category Name
Data Type: Text
Note that no options are available to set the seed or increment values in Design view.
Additional query words: prb ActiveX Data Objects ADO
Keywords : kbdta
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbprb
Last Reviewed: May 13, 1999