To query Data Definition (DDL) in Access, you use COUNTER to define the AutoNumber field. You tried to use both Integer and COUNTER in the same field, and this will not work.
I just tried this and it worked for me in Access 2010:
ALTER TABLE PERSON ALTER COLUMN PERSON_ID COUNTER PRIMARY KEY
Please note that in order for this statement to work
- the table should be empty, and
- The table should not have a primary key, even in the [PERSON_ID] field.
If the table already has rows, Access will not allow you to convert the Numeric (Long Integer) field to AutoNumber . In this case, you need to create a new table with the AutoNumber primary key, and then insert the rows from the old table into the new table.
For example, for an existing table named [PERSON] with columns
PERSON_ID INTEGER
TEXT PERSON_NAME (50)
you need to create a new table
CREATE TABLE PERSON_NEW (PERSON_ID COUNTER PRIMARY KEY, PERSON_NAME TEXT(50))
and then copy the records over
INSERT INTO PERSON_NEW SELECT * FROM PERSON
Gord thompson
source share