473,545 Members | 529 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can I add records form a table and related records another table to a third table?

Hi there,

I having a problem with a database I'm setting up, I would be
delighted if someone out there could help.

The database I'm setting up is a task register datebase, it will be
used to create work schedules for workers in a metal work shop, based
on the tasks required to make a part and the tasks required to make
the subcomponents of the part.

In the DB I have three main tables; the first table is called Parts
with a related table called SubComponents the third table is called
Tasks. I want to be able to select a record from the Parts table and
add it and its related records from the SubComponents table to the
Tasks table. The desired result is to have a list of all tasks that
need to be completed to make the required parts and their sub
components.

Could anyone advise me on how to achieve this?

Thank you in advance,

Colm
Nov 12 '05 #1
2 3048
Colm O'Hagan wrote:
Hi there,

I having a problem with a database I'm setting up, I would be
delighted if someone out there could help.

The database I'm setting up is a task register datebase, it will be
used to create work schedules for workers in a metal work shop, based
on the tasks required to make a part and the tasks required to make
the subcomponents of the part.

In the DB I have three main tables; the first table is called Parts
with a related table called SubComponents the third table is called
Tasks. I want to be able to select a record from the Parts table and
add it and its related records from the SubComponents table to the
Tasks table. The desired result is to have a list of all tasks that
need to be completed to make the required parts and their sub
components.

Could anyone advise me on how to achieve this?

Thank you in advance,

Colm


If you have a Parts table and Sub-Components then then if you pass the
PartNo (whatever is your primary key) then the task record would have
access to all of the information on that part. IOW, simply append the
PartID to the task record.

Let's say a part has 3 components. Would that be 3 tasks? If so, you
would then want to add the component key to the task record...it
wouldn't be necessary to add the Parts key.

PartsTable
PartID
PartDescription
SubParts
SubPartID
PartID
SubPartsDescrip tion

Tasks
TaskID
SubPartID
Date....

You can link back based on the subpartid to the subparts table that will
link you to the parts table.

You can add the record via an append query. See Append Query in help.
Also look at the Execute method in help.

You can add via a recordset. Using DAO (code similar to below would be
added in an event procedure under the button or control that would add
the record)

Dim strSQL As STring
Dim rst As Recordset
Dim rstTask As REcordset

Set rst = Currentdb.Openr ecordset("Tasks ",dbopendynaset )

strSQL = "Select SubPartID From SubPart Where " & _
"PartID = " & Me.PartID
set rst = currentdb.openr ecordset(strSQL ,dbopensnapshot )
If rst.RecordCount > 0 then
Do while not rst.Eof
rstTask.AddNew
rstTask!SubPart ID = rst!
rstTask.Update
rst.MoveNext
loop
endif
rst.close
rstTask.close
set rst = Nothing
set rstTask = Nothing

The above selects all sub part records for the part number (Me.PartID)
that you have selected and loops through the set, adding a task record
for each subpart.

Is a part made up of subcoms or parts and sub coms separate units. If
so, you may want to have a task record that contains the part number and
have another table SubTasks that links to Tasks and then have each
part and all sub components in it with detail. You could put in a code
field like P for Part and S for SubComponent.

Setting up the task table correctly will be crucial to you if you want
this to succeed.


Nov 12 '05 #2
Hi Salad,

Thanks for the help. I putting it into action now.

I have one more related question.

I have a form with a subform. On the form I have a text box
'NoOfParts' I want to press a button and have the value entered in
this text box 'NoOfParts' to be copied to another text box in the
subform. If you could help me with the code for this I would be
delighted.

Thanks again,

Colm
Salad <oi*@vinegar.co m> wrote in message news:<D4******* ************@ne wsread1.news.pa s.earthlink.net >...
Colm O'Hagan wrote:
Hi there,

I having a problem with a database I'm setting up, I would be
delighted if someone out there could help.

The database I'm setting up is a task register datebase, it will be
used to create work schedules for workers in a metal work shop, based
on the tasks required to make a part and the tasks required to make
the subcomponents of the part.

In the DB I have three main tables; the first table is called Parts
with a related table called SubComponents the third table is called
Tasks. I want to be able to select a record from the Parts table and
add it and its related records from the SubComponents table to the
Tasks table. The desired result is to have a list of all tasks that
need to be completed to make the required parts and their sub
components.

Could anyone advise me on how to achieve this?

Thank you in advance,

Colm


If you have a Parts table and Sub-Components then then if you pass the
PartNo (whatever is your primary key) then the task record would have
access to all of the information on that part. IOW, simply append the
PartID to the task record.

Let's say a part has 3 components. Would that be 3 tasks? If so, you
would then want to add the component key to the task record...it
wouldn't be necessary to add the Parts key.

PartsTable
PartID
PartDescription
SubParts
SubPartID
PartID
SubPartsDescrip tion

Tasks
TaskID
SubPartID
Date....

You can link back based on the subpartid to the subparts table that will
link you to the parts table.

You can add the record via an append query. See Append Query in help.
Also look at the Execute method in help.

You can add via a recordset. Using DAO (code similar to below would be
added in an event procedure under the button or control that would add
the record)

Dim strSQL As STring
Dim rst As Recordset
Dim rstTask As REcordset

Set rst = Currentdb.Openr ecordset("Tasks ",dbopendynaset )

strSQL = "Select SubPartID From SubPart Where " & _
"PartID = " & Me.PartID
set rst = currentdb.openr ecordset(strSQL ,dbopensnapshot )
If rst.RecordCount > 0 then
Do while not rst.Eof
rstTask.AddNew
rstTask!SubPart ID = rst!
rstTask.Update
rst.MoveNext
loop
endif
rst.close
rstTask.close
set rst = Nothing
set rstTask = Nothing

The above selects all sub part records for the part number (Me.PartID)
that you have selected and loops through the set, adding a task record
for each subpart.

Is a part made up of subcoms or parts and sub coms separate units. If
so, you may want to have a task record that contains the part number and
have another table SubTasks that links to Tasks and then have each
part and all sub components in it with detail. You could put in a code
field like P for Part and S for SubComponent.

Setting up the task table correctly will be crucial to you if you want
this to succeed.

Nov 12 '05 #3

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

Similar topics

3
11090
by: Jason | last post by:
I am trying to filter records in a primary form based on records in related tables. The data in the related tables is being displayed in the primary form through subforms. To be more specific, I have a primary form named TestResults, which is connected to data in a table named TestResults. There are basically two other tables that are...
1
2495
by: Dave | last post by:
I have a form which is based on a table (a) with over 6000 records.I have a button on this form which will open another form with related data from another table (b). What I want to do is open the second form and see the related data or if it hasnt got any related data create a new record in table (b) so that I can input data. If possible I...
2
294
by: Colm O'Hagan | last post by:
Hi there, I having a problem with a database I'm setting up, I would be delighted if someone out there could help. The database I'm setting up is a task register datebase, it will be used to create work schedules for workers in a metal work shop, based on the tasks required to make a part and the tasks required to make the subcomponents...
6
3079
by: Paul T. Rong | last post by:
Dear all, Here is my problem: There is a table "products" in my access database, since some of the products are out of date and stopped manufacture, I would like to delete those PRODUCTS from the table, but I was not allowed to do that, because "there are records related with those PRODUCTS in other tables (e.g. in table "ORDER_DETAIL").
12
12240
by: jaYPee | last post by:
I have currently using a dataset to access my data from sql server 2000. The dataset contains 3 tables that is related to each other. parent/child/grandchild relationship. My problem is it's very slow to retrieve records from sql server. I'm using sqldataadapter.fill method to populate dataset. Parent table contains more than 3,000 records...
2
1613
by: jaYPee | last post by:
I have no problem setting the selectcommand in sqldataadapter to fetch record from sqlserver w/ where clause in parent table. however, my problem is on how can i fetch the child table which is related from the parent table. I have ask this before and may be have not explained it well that's why i can't still get what i need. i have three...
3
8048
by: wvmbark | last post by:
First time poster... I just found this forum and it appears there's plenty of people here that could make short work of problem that's been driving me absolutely bonkers for months. Every day we incur numerous service problems “Events”. Each morning we have a global conference call where events which occurred within the previous 24 hours are...
11
3653
by: shriil | last post by:
Hi I have this database that calculates and stores the incentive amount earned by employees of a particular department. Each record is entered by entering the Date, Shift (morn, eve, or night) and the 'employee name'. There is another table which assigns an ID to the Shifts, i.e. 1,2 and 3 for morn, eve & night shifts respectively. From...
4
2148
by: jbrumbau | last post by:
Hello, I have been successfully using a database I've created for several months to populate an equipment list for a project we've been working on. However, the form has recently stopped working for some unknown reason. I've been having a problem recently where one table (Project Info) keeps auto-incrementing when I try to create a new record...
0
7465
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7398
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...
0
7656
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7805
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...
1
7416
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...
0
7752
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...
1
5325
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...
1
1013
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
701
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.