Lewiy
Well-known Member
- Joined
- Jan 5, 2007
- Messages
- 4,284
Have just started experiencing some very strange behaviour in Access 2016. This is happening even on a brand new database with one table.
E.g. I have set up a table with an ID field as primary key and data type of autonumber along with a couple of other short text fields. I enter some data just fine, say three rows. Then I run some SQL via VBA with the intention of creating a new data item with the same data as the row with ID 1:
When executing the code, I get an error saying that the row was not inserted because of a primary key duplication.
When I then return to the table and try to enter a new data row manually, I see that the autonumber is setting to '2' which is a duplication of the second data row and therefore won't allow me to enter any new rows of data. I've never seen this before. Any ideas?
E.g. I have set up a table with an ID field as primary key and data type of autonumber along with a couple of other short text fields. I enter some data just fine, say three rows. Then I run some SQL via VBA with the intention of creating a new data item with the same data as the row with ID 1:
VBA Code:
Dim sqlNewVersion As String
sqlNewVersion = "INSERT INTO [dataItems] SELECT * from [dataItems] WHERE [ID] = 1"
DoCmd.RunSQL sqlNewVersion
When executing the code, I get an error saying that the row was not inserted because of a primary key duplication.
When I then return to the table and try to enter a new data row manually, I see that the autonumber is setting to '2' which is a duplication of the second data row and therefore won't allow me to enter any new rows of data. I've never seen this before. Any ideas?