Copying a record and all of it's related records

mswarner

New Member
Joined
Nov 23, 2002
Messages
3
I have a main table with 3 different tables related to it. I'm using them in a form with 3 sub forms. I'd like to add a copy button that copies the record from the main table as well as the related records in the other tables. The key between the records is an autonumber field.

The copy should retain the relationships in the new records. I'd also like to prompt the user for certain info to update in the new main record.

Any help would be appreciated!

MRS :p
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Could you explain a little bit about what these tables are and the relationships between them? And what you are trying to do by copying the information from one table to others?

It is difficult to tell based on what you have provided so far, but there may be some designs flaws with your database, as you shouldn't have hte same data repeated in multiple tables if your all your tables are in Normal form.
 
Upvote 0
Speaking very generally, you'll have to do this:

1) Identify the specific record. Most likely candidate, the Autonumber field as a unique key.
2) Copy the primary table record values and paste them into the destination table.
3) Copy each of the secondary table record values (related records) and paste them into the appropriate table locations

Step 3 must be done after Step 2 if you are to maintain referential integrity in the destination tables.

Note: You will only be able to copy the autonumber_keyfield value into a regular number field. You can't paste values into an autonumber field (for the destination table)
-
I have a suspicion I know what you're trying to do.
You're copying records to a set of working tables, possibly for use by somebody else. Almost sounds like you've got a supervisor distributing work to others.

If yes, jmiskey is 100% correct about his design flaws comment.
Still working on an assumption, one way you could do this (instead of copying records) is by flagging records in some fashion instead. Use a Boolean field that is by default set to no and instead of copying records set it to True or Yes.

This has the advantage of not duplicating data or requiring you to overwrite the original data.

From here you'd probably open the table as a filtered recordset (filter parameter would be the boolean field=True)

Mike
 
Upvote 0
Thanks guys!

The main table is a business requirements table which holds basic info on a particular business requirement. The three related tables are

1) Tests associated with the requirement
2) Technical documentation associated with the requirement
3) Changes to the requirement

Each subtable is related to the main requirement based on the autonumber of that requirement, but that is the only piece of info shared between the tables.
 
Upvote 0

Forum statistics

Threads
1,221,692
Messages
6,161,351
Members
451,697
Latest member
pedroDH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top