Deleting data

P

Paul S

How can I delete data that has relationships. For example I have a talble
for clients and another table for individual members. So they are related.
When I try to delete a particular person, ACCESS tells me I can't do it
because the table is related to another table (sub-form). Any help would be
greatly appreciated.
 
P

PC Datasheet

Go to the Relationships window and click on the relationship line between
your two tables. Check Cascade Delete. When you delete a client, all
associated members of the client will also be deleted.

BTW, if you are getting a warning message when you try to delete, add the
following to your code:
DoCmd.SetWarnings False
<Your delete code>
DoCmd.SetWarnings True


--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
[email protected]
www.pcdatasheet.com

If you can't get the help you need in the newsgroup, I can help you for a
very reasonable fee. Over 1000 Access users have come to me for help.
Need a month calendar or 7 day calendar? Need appointment scheduling? Need
room reservations scheduling? Need employee work scheduling? Contact me!
 
J

Jeff Boyce

Paul

Let's say you have a Persons table and a HolidayGreetings table. One Person
can have sent out many Holiday Greetings.

If you were able to delete a person from the Persons table, what would you
want to have happen to the information in the HolidayGreetings table?

If you want to have all those (related) HolidayGreetings records deleted
too, PCD/Steve's approach would work.

If you don't want to have those deleted, DON'T delete the person in the
first place.

Step back for a second ... can you describe what you are trying to
accomplish, rather than "how"?

Regards

Jeff Boyce
<Office/Access MVP>
 
Top