delete child records in subtable when parent record deleted

G

Guest

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 :)
 
G

Guest

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

Guest

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 :)
 
G

Guest

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top