merging databases

M

Miles

I have an Access 2003 database containing about 150
tables. Almost all of the tables use an autonumber field
as a primary key. How do I merge records from two copies
of the same database from two different users? The
problem is that the autonumber fields will overlap. One
solution I thought of is to use a two field primary key
for each table where one field was an autonumber field
and the second field is a unique user id. Is this the
only way to do it? Are there better ways?

Thks Miles.
 
M

Marin Kostov

Use Append Query.
Here is how to do it:
Let's say, you have two tables, tblMain, which is the first table, and
tblSecond, which contains the records you need to append to the first table.
So, open the Queries object, and create new Query in Design View. In the
Show Table dialog, select tblSecond and click Add. Close the window.
Then change the Query to Append. In the Append to select tblMain.
Drag all fields from tblSecond to the lower pane, except the Primary Key.
Then click the ! sign to run the Query.
Answer Yes to the question.
You are ready. You have append the fields, and the Autonumber is generated
by Access. You don't need to worry about it.
 
D

Duane Hookom

With 150 tables, I expect there are tables with records related to
autonumbers from other tables. A simple append query will not update the
related records.

You could try run code that would set all of the autonumber fields in the
"copies" to standard, long integer fields. If you have referential integrity
set on with cascade updates, you should be able to update the previous
autonumber fields to numbers greater than the autonumber fields in the
original mdb. This should allow you to append the records from the copies to
ther original. NOTE: I would test this prior to doing this with live mdbs.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top