Results 1 to 7 of 7
  1. #1
    acrowe97 is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Aug 2018
    Posts
    41

    Cascade delete to a point?


    I have a database that contains info on tenants in a building. My current relationship leads as follows: Tenant ID is a foreign key in a table with a Lease ID, which in turn is a foreign key in a table with a Suite number. Suite numbers generally do not change, but can. When a tenant moves/leaves the building, I want to be able to delete the Tenant ID and Lease ID, without deleting the info on the suite number, as the suite number is used as a foreign key in about 7 other tables. Any way I can do this? I can post pictures of my relationships if need be. Thanks.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    tBldg table should have an Suite# and TenantID field and LeaseID. Set [TenantID] and [LeaseID] to null with an update query.
    user selects the bldg and apt#, clicks button to Remove Tenant, then it runs the query.

    but the data should remain in the tBldgHist table. (for historical records)

  3. #3
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I can post pictures of my relationships if need be.
    Yes, it would help to see your tables and relationships...

  4. #4
    accesstos's Avatar
    accesstos is offline Expert
    Windows XP Access 2007
    Join Date
    Dec 2018
    Location
    Greece
    Posts
    551
    Deleting data it is not a good practice.
    Create a table that keeps the Lease ID and some details of suites release (date, reason etc).
    With an outer join on the Lease ID, you can take only those leases that have a null field on releases side.

    I hope that you understand me.

  5. #5
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    I agree with Accesstos,

    a field such as Date_Left or something like hat to indicate when they moved out. You can then exclude any records that you want.

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Here is an older draft model that dealt with Tenancy in response to a post.
    It might offer some insight on relationships and serve as a starting point.

    Good luck

    Click image for larger version. 

Name:	Tenancy.jpg 
Views:	7 
Size:	63.9 KB 
ID:	36770

  7. #7
    acrowe97 is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Aug 2018
    Posts
    41
    Thank you all for the advice! Much appreciated. I have a lease end date field so I will use that as a constraint for displaying information.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Pragmatically Cascade Delete
    By kd2017 in forum Programming
    Replies: 2
    Last Post: 09-26-2017, 05:50 PM
  2. Cascade Delete when Its not set?
    By Perceptus in forum Queries
    Replies: 16
    Last Post: 10-13-2015, 01:21 PM
  3. Delete Zero after decimal point!
    By cuongmyh in forum Forms
    Replies: 1
    Last Post: 02-26-2015, 07:06 AM
  4. Replies: 1
    Last Post: 11-21-2011, 07:52 PM
  5. On delete cascade fails in constraint clause
    By Victor EGBE in forum Queries
    Replies: 0
    Last Post: 03-02-2009, 09:52 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums