Results 1 to 3 of 3

Thread: Set Default on Delete problem

  1. #1
    Join Date
    May 2004
    Location
    London UK
    Posts
    1

    Unhappy Set Default on Delete problem

    Hello all...

    First let me say that these forums are invaluable and it is nice to see people helping each other out.

    This is my first message and the problem I have is that I have is with setting a table to do Set Default for all foreign keys when I delete a table.

    For example I have two tables that are linked, Donors and Donations. Each Donor has a unique ID (Donor_ID). The Donor_ID is stored in the Donations table as a foreign key to link these tables. When I delete a Donor what I would like it to do is to set all related records in the Donations table to a default value i.e. it would change the Donor_ID in the Donation Table to a "DON1". How do I go about doing this in MS Access? I have seen how it is done in SQL but how do I incorporate this in Access. Please let me know and thank you in advance

  2. #2
    Join Date
    Jan 2003
    Location
    UK
    Posts
    277
    Just prior to deleting the donor can you run an Update query to update the donorID (of the one you wish to delete) in the Donations table to DON1.

    You will need to have a Donor in the donor table with a donorID of DON1 in order for the 1 to many relationship to work and also the update.

    Hope that makes sense ?

  3. #3
    Join Date
    Apr 2004
    Posts
    20
    If you delete a Donor form a datasheet (Browsing) view of Donor table, you cannot update the Donations table. (Access doesn't have Store Procedure).
    So best way to do that is to intercept the delete event inside a form showing Donor records; in the event procedure you can run an update query (to change the Donor_ID to "DON1") then you can delete the Donor Record.
    Let me know if this solve your problem.

    CIAO

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •