What I try is to import several tables programmatically from Microsoft SQL Server to Microsoft Access.
Each SQL Server table has an identity column, and the correspo
The secret is to temporarily un-assign the autonumber as the primary key. This allows Appending AutoNumber Field to your records without any trouble (just make sure you do not have any duplicates when appending, otherwise when you re-assign the primary key you will get an error).
If you use Insert Into
and specify all column names in MS Access, it should work.
I just created a table with the following structure
Id (autonumber)
Firstname (text)
Secondname (text)
Lastname (text)
I ran this statement
docmd.RunSQL "insert into table2 (id, firstname, secondname, lastname) values (27, 'a', 'b', 'c')"
It worked and inserted 27 into the autonumber column
Assuming you can see both the SQL Server tables (linked tables) and the MS Access tables while in the MS Access database, here is the procedure to do it without code. These instructions are for Access 2013, so while interface elements have moved, this should work for 2003, 2007, etc.
Your Access table into which you are importing should be free of any data.
*
field if all column names match and you want to import all fields.Access will tell you how many records you are about to append - you can use this information to verify that you are getting all your data.
You can save this query if you think you'll need to use it again to sync the tables.
If you want to get fancy, you could create a delete query which deletes all the records in the access table, then create a macro which runs everything in this order: