PC Review


Reply
Thread Tools Rate Thread

delete child records in subtable when parent record deleted

 
 
=?Utf-8?B?YWZ0M3JnbDB3?=
Guest
Posts: n/a
 
      11th Nov 2006
hey everyone, having problems with this one..
i have 2 tables, used for a waybill. parent table holds the waybill info
and has a UID field... this field is linked to a subtable which holds up to 8
records of cargo information. it has a uid field. it also has a second
field called link_id that is the link to the the parent record, using the UID
from the parent.
what i want is when i delete the parent record to have all the corresponding
child cargo entries to be deleted. do i need to add code to the delete
button for the parent record? thanx in advance for any help
 
Reply With Quote
 
 
 
 
=?Utf-8?B?VG9ueVQ=?=
Guest
Posts: n/a
 
      11th Nov 2006
Hi aft3rgl0w,

If you have 'cascade delete' selected and the tables are joined, Access will
delete the child records without any further code required. If cascade delete
is not checked, then you will need to use an SQL command to delete the child
records by way of code.
By far the best route is to enable cascade delete though, as a user deleting
the record in a table directly still deletes the child records.

hope this helps,

TonyT..


"aft3rgl0w" wrote:

> hey everyone, having problems with this one..
> i have 2 tables, used for a waybill. parent table holds the waybill info
> and has a UID field... this field is linked to a subtable which holds up to 8
> records of cargo information. it has a uid field. it also has a second
> field called link_id that is the link to the the parent record, using the UID
> from the parent.
> what i want is when i delete the parent record to have all the corresponding
> child cargo entries to be deleted. do i need to add code to the delete
> button for the parent record? thanx in advance for any help

 
Reply With Quote
 
=?Utf-8?B?YWZ0M3JnbDB3?=
Guest
Posts: n/a
 
      11th Nov 2006
where do i enable cascade delete? can't find it in any of the settings and
the help file doesn't mention anything on it.... thanx

"TonyT" wrote:

> Hi aft3rgl0w,
>
> If you have 'cascade delete' selected and the tables are joined, Access will
> delete the child records without any further code required. If cascade delete
> is not checked, then you will need to use an SQL command to delete the child
> records by way of code.
> By far the best route is to enable cascade delete though, as a user deleting
> the record in a table directly still deletes the child records.
>
> hope this helps,
>
> TonyT..
>
>
> "aft3rgl0w" wrote:
>
> > hey everyone, having problems with this one..
> > i have 2 tables, used for a waybill. parent table holds the waybill info
> > and has a UID field... this field is linked to a subtable which holds up to 8
> > records of cargo information. it has a uid field. it also has a second
> > field called link_id that is the link to the the parent record, using the UID
> > from the parent.
> > what i want is when i delete the parent record to have all the corresponding
> > child cargo entries to be deleted. do i need to add code to the delete
> > button for the parent record? thanx in advance for any help

 
Reply With Quote
 
=?Utf-8?B?VG9ueVQ=?=
Guest
Posts: n/a
 
      11th Nov 2006
Hi again,

If you go into the relationship's screen from the main Access startup window
(button depicting 3 forms) then right click on each of the joins shown
between you tables, you will get 3 check box options if you choose 'Edit
Relationships'. Tick all 3 to get Access to update and delete child records
and enforce referencial integrity. You may have to delete any orphan records
from the child table to be able to implement this change, Access will check
that the current data meets the requirements of integrity before it will
allow the change and will prompt accordingly.

TonyT..


"aft3rgl0w" wrote:

> where do i enable cascade delete? can't find it in any of the settings and
> the help file doesn't mention anything on it.... thanx
>
> "TonyT" wrote:
>
> > Hi aft3rgl0w,
> >
> > If you have 'cascade delete' selected and the tables are joined, Access will
> > delete the child records without any further code required. If cascade delete
> > is not checked, then you will need to use an SQL command to delete the child
> > records by way of code.
> > By far the best route is to enable cascade delete though, as a user deleting
> > the record in a table directly still deletes the child records.
> >
> > hope this helps,
> >
> > TonyT..
> >
> >
> > "aft3rgl0w" wrote:
> >
> > > hey everyone, having problems with this one..
> > > i have 2 tables, used for a waybill. parent table holds the waybill info
> > > and has a UID field... this field is linked to a subtable which holds up to 8
> > > records of cargo information. it has a uid field. it also has a second
> > > field called link_id that is the link to the the parent record, using the UID
> > > from the parent.
> > > what i want is when i delete the parent record to have all the corresponding
> > > child cargo entries to be deleted. do i need to add code to the delete
> > > button for the parent record? thanx in advance for any help

 
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
How to query for Parent Records with no matching Child Record? Will Microsoft Access 1 31st Oct 2007 08:28 PM
Assign Child Records from Template Parent Record to Current Parent Record BCW Microsoft Access ADP SQL Server 1 2nd May 2006 07:01 PM
HELP w/Coding Delete Parent/Child Records =?Utf-8?B?Sm9obkx1dGU=?= Microsoft Access Form Coding 0 26th Aug 2004 06:37 PM
Help Coding Delete Child/Parent Records =?Utf-8?B?Sm9obkx1dGU=?= Microsoft Access Form Coding 15 9th Aug 2004 01:47 PM
How can I limit the number of child records per parent record? John Yung Microsoft ADO .NET 2 5th Nov 2003 02:27 PM


Features
 

Advertising
 

Newsgroups
 


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