help!! urgent data import problem

  • Thread starter Thread starter dan
  • Start date Start date
D

dan

PLEASE, PLEASE, can someone help.

I've got two databases with the same structure and I want
to import the data from one of the databases into the
other.

I thought it would be really easy, but I think I may be
missing something. I went to file/import, and selected
the mdb and the tables. but when access imported the
tables it didn't append the table contents, it created
duplicate tables but with a 1 appended to the name. e.g.
contacts1. I want to insert contents from one table in
one database to the same named table in another. please
help!!!!

Cheers,

dan.
 
Dan,

First, in the database which is to receive the data, link each of the tables
in the other database by using File|Get External Data|Link. Then, you will
need to create an Append query for each of the linked tables, appending each
of its fields to the local table. As long as the structure of each linked
table is exactly the same as its counterpart local table, you could use a
SQL string like the following, just changing the table names appropriately:

INSERT INTO [MyTable]
SELECT [MyLinkedTable].*
FROM [MyLinkedTable]

You can insert this code into the SQL view of any query design.

Or, you could do these in code, putting the following behind a command
button on a form:

CurrentDB.Execute "INSERT INTO MyTable SELECT MyLinkedTable.* from
MyLinkedTable", dbFailOnError
' continue with another Execute using different tables


hth,
 
Back
Top