Create table with Autonumber in MS ACCESS

musson
10-26-2004, 08:15 AM
Create table with Autonumber in MS ACCESS
Hi,

I have a probably simple problem.

I need to create a new table in my MS Access db. I need a primary key with Autonumber.

I need to do this with a SQL expression like.
CREATE TABLE MYTAB
(MY_ID LONG)

But something more is needed to make the MY_ID field autonumber.

Anyone who know how i can make it autonumbering?

Brg
/Musson

Flyguy
10-26-2004, 08:33 AM
Based on some old code lying around:

SQL = SQL & " ID AUTOINCREMENT CONSTRAINT PK_CardData PRIMARY KEY"
' Where:
' ID is the primary key
' PK_CardData => PK_"TableName"

musson
10-26-2004, 08:48 AM
Thanx alot FlyGuy

That helped. my final SQL turned out like this
CREATE TABLE ERROR_LIST
(ERR_ID AUTOINCREMENT CONSTRAINT ERR_ID PRIMARY KEY,
LAB_ID LONG,
ERR_NO LONG,
ERR_SOURCE VARCHAR(250),
ERR_DESC VARCHAR(250),
ACK_USER VARCHAR(10),
ACK_DATETIME VARCHAR(50))

/Musson

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum