473,396 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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_details.

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

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

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

Specification Table has the following fields:

specification_ID (Autonumber)
product_ID (Number)
specification_header (Text)

Specification_detail Table has the following fields:

specification_detail_ID (Autonumber)
specification_detail_text (Text)
specification_ID (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_header)
"
MySql4 = MySql4 & "SELECT " & NewProductCode & " as NewProductID,
Specifications.specification_header 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 2617
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_details.

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

The problem I am having is copying the Specification_details to the new
product.
So walk down the relationships - grab the PK of the parent record of
Specification_details, 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
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...
3
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...
19
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
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...
4
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...
3
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....
2
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...
0
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...
5
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
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,...

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.