问题
I'm trying to do (basically) an automated row copy from one backend to another as the backend is being used but is not fully developed (some tables are done, others not; adding the completed data into the more advanced db at the end of the day).
I'd like to know what the syntax is for an SQL statement which:
INSERT INTO tblMyBetterTable * IN "C:\\path_to_db\db.accdb"
FROM tblMyTable IN "C:\\path_to_in_use_db\in-use-db.accdb"
The syntax is not correct but I've searched for a while and can't find out how.. I've seen how to import from one table to another etc, but not across backends. If it's not clear, I'd like to basically do a table copy of all rows in in-use-db.accdb
from tblMyTable
to the latest version of the backend db.accdb
's table tblMyBetterTable
.
回答1:
I suggest you try DoCmd.TransferDatabase
For a query, you need something on the lines of:
SELECT * INTO NewTable
FROM [;DATABASE=Z:\Docs\Test.accdb].Table1
Or the other way round:
SELECT * INTO [;DATABASE=Z:\Docs\Test.accdb].NewTable
FROM Table1
To insert into an existing table:
INSERT INTO table1
SELECT *
FROM [;DATABASE=Z:\Docs\Test.accdb].Table1
来源:https://stackoverflow.com/questions/10918605/syntax-for-import-into-from-different-dbs-ms-access