Programmatically add AutoNum

G

Guest

Using Office 2003 and Windows XP;

I thought the following SQL would append an AutoNum to an existing table:

Dim sSQL As String
sSQL = "ALTER TABLE [tblMyTable] ADD COLUMN ([RecordID] IDENTITY (1, 1));"
CurrentDb.Execute sSQL

But, I get "Syntax error in field definition"; Does anyone know how to get
this right?

Thanks much.
 
M

Marshall Barton

XP said:
Using Office 2003 and Windows XP;

I thought the following SQL would append an AutoNum to an existing table:

Dim sSQL As String
sSQL = "ALTER TABLE [tblMyTable] ADD COLUMN ([RecordID] IDENTITY (1, 1));"
CurrentDb.Execute sSQL

But, I get "Syntax error in field definition"; Does anyone know how to get
this right?


I think(?) this would be the Jet equivalent:

ALTER TABLE tblMyTable
ADD COLUMN RecordID COUNTER
CONSTRAINT pk PRIMARY KEY
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top