473,785 Members | 2,154 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Copy related sub records ............

Hi,

I have an MS Access app which lets me create a new product by copying
data from another selected product.
All works fine, except one of the copy updates which I cannot fathom.

The code creates a new product and copies over the parent data from the
other product first.
Then related data from other tables is copied accross using the new
Product_ID. ok

One of the relate records 'specifications ' are copied accross to the
new Product.
The problem is that Specifications also have a related sub table called
Specification-details.

On my app, you select a product and then select the specifications form
from a combo.
On this specifications form, there is the Specification data in a
continuous format, and another sub-form with specification_d etails.

When you click on a specification, the relevant specification_d etail
appears in the sub-form below. This is pretty standard.

The problem I am having is copying the Specification_d etails to the new
product.

---------------------------------------------------

Specification Table has the following fields:

specification_I D (Autonumber)
product_ID (Number)
specification_h eader (Text)

Specification_d etail Table has the following fields:

specification_d etail_ID (Autonumber)
specification_d etail_text (Text)
specification_I D (Number) related to Specification table !

--------------------------------------------------------

This code copies the parent 'Specifications ' over to the new product
and works great.
(NewProductCode = the new Product_ID)
(currentid = The Product_ID of the product to copy)

MySql4 = "INSERT INTO Specifications (product_ID, specification_h eader)
"
MySql4 = MySql4 & "SELECT " & NewProductCode & " as NewProductID,
Specifications. specification_h eader FROM Specifications "
MySql4 = MySql4 & "WHERE Specifications. product_ID = " & currentid
db.Execute MySql4, dbFailOnError

----------------------------------------------------------

How do I copy the related 'Specification_ details' over to the new
product as there is no Product_ID in this table. The related field is
'Specification_ ID'

Appreciate all your help

Thanks in advance

David Gordon

Jul 18 '06 #1
1 2638
On my app, you select a product and then select the specifications form
from a combo.
On this specifications form, there is the Specification data in a
continuous format, and another sub-form with specification_d etails.

When you click on a specification, the relevant specification_d etail
appears in the sub-form below. This is pretty standard.

The problem I am having is copying the Specification_d etails to the new
product.
So walk down the relationships - grab the PK of the parent record of
Specification_d etails, and then use an append query with that PK/FK as
the filter, and then append to the table it should go in. if you're
missing records or something hasn't saved, well then deal with that
problem first - force Access to save the record.

Jul 19 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
1311
by: John Baker | last post by:
Hi: I have set up a table, and a temporary copy of the table which I wish to use for some processing. I have found that using a query to empty the ORIGINAL table, the copy of the table gets emptied too. Both are in the same dfatabase and have different names. Can someone tell me how to breath that irritating link!
3
1981
by: JumpinJeff | last post by:
I need to create a copy of a record and *all* it's related data, from *all* it's related tables. The only exception is one of it's primary keys will be incremented. This app is an onging project for me, so I really dread manually quering every field in every table, because of all my upcoming changes, and because there are abbout 12 tables. I just want to be able to say "copy all related data and increment the key". Any ideas would be...
19
3479
by: davidgordon | last post by:
Hi, I need some pointers/help on how to do the following if it possible: In my access db, I have the following: Tables: Products, Sub-Assembly, Product-Pack Table, Products
0
2153
by: igendreau | last post by:
I have a database with a Header table. Each record in tblHeader has two One-to-Many Relationships: with tblLines and tblKeys. The HeaderID field ties tblHeader to the other two tables. The data collected in tblHeader is simple: HeaderID (unique), a text description field, and a date field. I need to be able to copy header and it's related info. I have a form with a "Copy Source" combo box allowing the user to select a Header...
4
1679
by: Wout | last post by:
Hello there, i have a main form to define products in. i have a subform1 to fill in the related materials i have a subform2 to fill in the machines to process the materials subform1 is related to mainform through "ProductId", subform2 is related to subform1 through "MaterialId" both subforms are displayed on the mainform. i need to find out how i can copy a product-record including all
3
2796
by: Swinky | last post by:
I hope someone can help me...I haven't got a clue how to do this. I have a table with several one-to-many relationships. One of the related tables has it's own one-to many relationships as well. I would like to copy a record when I am in a form and append it to the last record. To make it more complicated, I have an auto-number (primary key) on the main table and some of the related tables also. I can't do what I want to do using...
2
3469
by: Swinky | last post by:
I hope someone can help...I feel like I'm walking in the dark without a flashlight (I'm NOT a programmer but have been called to task to do some work in Access that is above my head). I have code that will successfully copy a record and append the information to a new record in the same table (parent table) within a form. However, there are related child tables with primary keys (set to Autonumber) stored in sub-forms. That information...
0
1649
by: cannonpm | last post by:
Greetings and salutations. I have developed an A2K3 MDB and have a search form modeled after Allen Browne's search form (http:// allenbrowne.com/ser-62.html). It works well except for records which have multiple related records in 1:many relationships and many:to:many relationships. To view my results, I created a query called qryAllData which contains all of the data from several tables for each record. For example, say I have one...
5
11155
by: phill86 | last post by:
Hi I have a main form that holds records for scheduled meetings, date time location etc... in that form i have a sub form that has a list of equipment resources that you can assign to the meeting in the main form. I have two buttons in the sub form one for selecting and copying all the records and another for pasting the records this enables me to copy and paste the equipment resources from one scheduled meeting to another. The buttons are...
0
9484
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10157
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10097
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9957
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8983
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7505
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5518
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4055
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3658
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.