deleting a record only if no child records exist

  • Thread starter Thread starter Meryl
  • Start date Start date
M

Meryl

I have a donor database where the donor table houses the
address information about the donor and the donations
table stores the individual donations for that donor.
It's a 1 to many relationship.

Sometimes a donor moves and we can't get their new
address. If they haven't made any donations, I want to be
able to delete the donor record.

How can I test if any child (donations) records exist for
a donor before deleting?

Thanks!
 
Create a relationship between the two tables, and check to enforce
referential integrity. Make sure you haven't got the Cascade Delete Related
Records box checked. Now, if you try to delete a record and there are
children records, Access will raise an error.
 
Back
Top