PC Review


Reply
Thread Tools Rate Thread

Automatically copying main and related sub records

 
 
Stephen Jame Pattenden
Guest
Posts: n/a
 
      23rd Jan 2009
I am trying to create a macro/vba that will automatically copy a master
record and its related sub records into a new master record with the same
related sub records.

Automatically copying the main record is simple, but being able to copy all
the related sub records and pasting them into a new main record - to which
they would then be related is proving to be quite difficult.

Any suggestions would be greatfully received.
 
Reply With Quote
 
 
 
 
Ken Snell \(MVP\)
Guest
Posts: n/a
 
      23rd Jan 2009
To copy the subrecords, you'll need to know the original master record's
primary key value, and the newly copied master record's primary key value.
Then you run an append query that uses the original master record's primary
key value in the WHERE clause for selecting the subrecords, and that uses
the newly copied master record's primary key value in the VALUES (or SELECT)
clause for the new subrecords' foreign key field.

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/


"Stephen Jame Pattenden" <(E-Mail Removed)>
wrote in message news:(E-Mail Removed)...
>I am trying to create a macro/vba that will automatically copy a master
> record and its related sub records into a new master record with the same
> related sub records.
>
> Automatically copying the main record is simple, but being able to copy
> all
> the related sub records and pasting them into a new main record - to which
> they would then be related is proving to be quite difficult.
>
> Any suggestions would be greatfully received.



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Filter main form to records with no related records in subform,maintain updateable recordset esn Microsoft Access Form Coding 4 3rd Sep 2011 01:07 AM
Combo box for related records AND non-related records rocketD Microsoft Access 3 16th Nov 2009 07:34 PM
Related records depend on other related records BruceM Microsoft Access Database Table Design 2 31st Oct 2008 12:46 PM
main form, sub form, sub sub form ...etc =?Utf-8?B?RGF3blRyZWFkZXI=?= Microsoft Access Form Coding 8 5th Nov 2006 05:26 AM
Re: Referencing main/sub then sub/main report controls for Calcs =?Utf-8?B?SmF5?= Microsoft Access Reports 0 22nd Oct 2004 05:19 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:51 PM.