PC Review


Reply
Thread Tools Rate Thread

Copying records from the "many" end of a relationship to a new ID on the "one" end

 
 
WOW News
Guest
Posts: n/a
 
      29th Mar 2007
Hello,
I need to copy a set of related records from the "Many" end of a "One to
Many" relationship. I don't know how to put this in words other than with
an example so here goes:

There is a table for Salespersons that is the "one" of a One to Many
relationship with several other tables (contacts, products, sales).
The primary key in the Salespersons table is SalespersonID which is linked
to many related records in each of the other tables.

If SalespersonID01 decides to leave the company or takes a different
position and we wish to add a new SalespersonID02 who will take over all the
same contacts, products, and sales, is there a way to copy all the related
records from SalespersonID01 to SalespersonID02?

I don't want to delete or reassign SalespersonID01 because I need the
historical records for that person. Basically I am trying to avoid having
to manually re-enter all the contacts, products, and sales for
SalespersonID02 by allowing the user to copy all the related data for
Salesperson01.

Thanks for any guidance you can provide!








 
Reply With Quote
 
 
 
 
Allen Browne
Guest
Posts: n/a
 
      29th Mar 2007
You can do that with an Append query.

1. Create a query using the table you want to duplicate records from.

2. Type in some criteria (e.g. SalepersonID01)

3. In a fresh column in the Field row, type in a number representing the
person you want to append to, e.g. SalespersonID02.

4. Change it to an Append query (Append on Query menu.)
Answer that you want to append to the same table.

5. Map the correct fields. You do NOT want to append to any field for the
one in step 2, but you DO want to append to the SalespersonID for the field
in step 3.

6. Once the query is correct, switch to SQL View (View menu.)
There is a sample of the query string you need to create in VBA code, to
execute.

If executing append queries in code is new, see the Execute part of this
article:
http://allenbrowne.com/ser-60.html
The basic idea is to concatenate the values into the string, so it adds the
correct information.

Here's another example:
Duplicate the record in form and subform
at:
http://allenbrowne.com/ser-57.html
This one shows how to duplicate the sales person and their related records.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"WOW News" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello,
> I need to copy a set of related records from the "Many" end of a "One to
> Many" relationship. I don't know how to put this in words other than with
> an example so here goes:
>
> There is a table for Salespersons that is the "one" of a One to Many
> relationship with several other tables (contacts, products, sales).
> The primary key in the Salespersons table is SalespersonID which is linked
> to many related records in each of the other tables.
>
> If SalespersonID01 decides to leave the company or takes a different
> position and we wish to add a new SalespersonID02 who will take over all
> the same contacts, products, and sales, is there a way to copy all the
> related records from SalespersonID01 to SalespersonID02?
>
> I don't want to delete or reassign SalespersonID01 because I need the
> historical records for that person. Basically I am trying to avoid having
> to manually re-enter all the contacts, products, and sales for
> SalespersonID02 by allowing the user to copy all the related data for
> Salesperson01.
>
> Thanks for any guidance you can provide!


 
Reply With Quote
 
WOW News
Guest
Posts: n/a
 
      3rd Apr 2007
That was just what I needed to get me "unstuck" - thanks very much!

"Allen Browne" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> You can do that with an Append query.
>
> 1. Create a query using the table you want to duplicate records from.
>
> 2. Type in some criteria (e.g. SalepersonID01)
>
> 3. In a fresh column in the Field row, type in a number representing the
> person you want to append to, e.g. SalespersonID02.
>
> 4. Change it to an Append query (Append on Query menu.)
> Answer that you want to append to the same table.
>
> 5. Map the correct fields. You do NOT want to append to any field for the
> one in step 2, but you DO want to append to the SalespersonID for the
> field in step 3.
>
> 6. Once the query is correct, switch to SQL View (View menu.)
> There is a sample of the query string you need to create in VBA code, to
> execute.
>
> If executing append queries in code is new, see the Execute part of this
> article:
> http://allenbrowne.com/ser-60.html
> The basic idea is to concatenate the values into the string, so it adds
> the correct information.
>
> Here's another example:
> Duplicate the record in form and subform
> at:
> http://allenbrowne.com/ser-57.html
> This one shows how to duplicate the sales person and their related
> records.
>
> --
> Allen Browne - Microsoft MVP. Perth, Western Australia
> Tips for Access users - http://allenbrowne.com/tips.html
> Reply to group, rather than allenbrowne at mvps dot org.
>
> "WOW News" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Hello,
>> I need to copy a set of related records from the "Many" end of a "One to
>> Many" relationship. I don't know how to put this in words other than
>> with an example so here goes:
>>
>> There is a table for Salespersons that is the "one" of a One to Many
>> relationship with several other tables (contacts, products, sales).
>> The primary key in the Salespersons table is SalespersonID which is
>> linked to many related records in each of the other tables.
>>
>> If SalespersonID01 decides to leave the company or takes a different
>> position and we wish to add a new SalespersonID02 who will take over all
>> the same contacts, products, and sales, is there a way to copy all the
>> related records from SalespersonID01 to SalespersonID02?
>>
>> I don't want to delete or reassign SalespersonID01 because I need the
>> historical records for that person. Basically I am trying to avoid
>> having to manually re-enter all the contacts, products, and sales for
>> SalespersonID02 by allowing the user to copy all the related data for
>> Salesperson01.
>>
>> Thanks for any guidance you can provide!

>



 
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
Field Names: "LongName", "ShortName", "Code", "Description","Comments" PeteCresswell Microsoft Access 2 25th Feb 2009 11:41 PM
ReVIEW (Erratum): some shortcut keys not working anymore-----help""""""""PhpApach...WORK WELL!!!! wbrowse@gmail.com Windows XP Help 0 13th Apr 2007 12:29 PM
<FORM METHOD="post" onSubmit="return fieldcheck()" name="orientation" action="http://ws-kitty.BU.edu/AT/survey/orientation/script/write.asp" language="JavaScript"> Joeyej Microsoft ASP .NET 0 4th Jun 2004 08:55 PM
Manual "Windows Update" produces "ActiveX/active scripting" error message even with "LOW" security level setting in "Trusted" Zone Ray2 Windows XP Help 1 14th Nov 2003 06:50 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:31 AM.