- Local time
- Today, 07:13
- Joined
- Oct 29, 2018
- Messages
- 21,473
Hi Colin,
In your list of "I didn't do any of the following:," I guess we could argue item (c) could have been worded as "intentionally reseed before uploading." Because the code you used:
Does reseed the Autonumber field by using COUNTER(1, 1) because it is saying start the counter at 1 and increment by 1.
Also, in your "Method 1," you said by using a make-table query,
I then opened the new tblData in Design view and see that the ID field is already set as an Autonumber data type. When I tried to add a new record to this new table, the ID field correctly used the next number in sequence (7).
The way I might fix Method 1 is as follows, rather than use the following DDL statement:
You could try using the following DDL statement instead:
When I opened your original table in design view, I noticed the weird name for your primary key index. I knew it had something to do with what happened, but I didn't think you were using code to cause the problem.
In your list of "I didn't do any of the following:," I guess we could argue item (c) could have been worded as "intentionally reseed before uploading." Because the code you used:
Code:
CurrentDb.Execute "ALTER TABLE tblData ALTER COLUMN ID COUNTER(1, 1) NOT NULL PRIMARY KEY;"
Also, in your "Method 1," you said by using a make-table query,
I agree with the first part but not the second part. As a test, I executed the following code in the Immediate Window:- This does not re-create the PK or the autonumber datatype
Code:
DoCmd.Close acTable, "tblData"
DoCmd.DeleteObject acTable, "tblData"
CurrentDb.Execute "SELECT tblDataBKP.* INTO tblData FROM tblDataBKP;"
The way I might fix Method 1 is as follows, rather than use the following DDL statement:
Code:
'add PK if not already done
CurrentDb.Execute "ALTER TABLE tblData ALTER COLUMN ID COUNTER(1, 1) NOT NULL PRIMARY KEY;"
Code:
CurrentDb.Execute "ALTER TABLE tblData ADD CONSTRAINT PK PRIMARY KEY (ID);"
Last edited: