Changing linked keys

G

Guest

I have a database where the designer linked tables by the Social Security
Number. I want to change that to an autonumber field in the names table and
a same name field in the related tables (type long)

Outside of an update query setting the number ID in the related tables, is
their another/better way to do this?
 
G

Guest

I think you are better off exporting the information, redesigning the tables
and establishing a new relationship.
 
J

John W. Vinson

I have a database where the designer linked tables by the Social Security
Number. I want to change that to an autonumber field in the names table and
a same name field in the related tables (type long)

Outside of an update query setting the number ID in the related tables, is
their another/better way to do this?

Not that I can think of. You'll need multiple queries, I'd guess, especially
if there is not yet an autonumber field or if there are additional linked
tables.

I'd do it in steps, working on a COPY of your database (not the production
instance.... shudder!!!)


1. Add the Autonumber filed to the names table. This might require creating a
new table and running an Append query to populate it.
2. Add a Long Integer foreign key field to each child table in design view.
3. Run update queries like

UPDATE [names] INNER JOIN [childtable1]
ON [names].SSN = [childtable1].SSN
SET childtable1.IDfield = names.IDfield;

for each child table.
4. Drop the relationships on SSN, establish new relationships between the new
ID fields
5. Delete the SSN fields from the child tables
6. Test everything: forms, reports, exports, etc.
7. Correct the inevitable errors (e.g. subforms depending on the SSN field
being available)
8. Put the new database into production

John W. Vinson [MVP]
 

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