Results 1 to 6 of 6
  1. #1
    LaughingBull is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Location
    Toledo Ohio
    Posts
    143

    Delete does not delete records in evey table

    I have a form to check out books data source is a query made up of 4 tablesClick image for larger version. 

Name:	LibraryCheckOut.jpg 
Views:	8 
Size:	57.6 KB 
ID:	21898 the code to prevent selecting a book already signed out is:

    Private Sub BookName_ID_BeforeUpdate(Cancel As Integer)
    If Forms!tblLibrary1!CheckedOut = True Then
    MsgBox "This book is checked Out Select another"
    End If
    End Sub



    and it works great. The problem is when I delete the record of a book that is checked out the record from the query and tables are deleted, but the yes/no field in the books table stays checked.

    Even though the record is deleted when I select a book that was checked out in the deleted record the message says the book is checked out until I go and uncheck the field in the books table.

    Any Ideas!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Would require code to edit the CheckedOut field. This field is not really required at all. The CheckedOut value can be calculated. Whether a book is checked out can be determined by a query of tblLibrary or with DLookup() domain aggregate function.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    LaughingBull is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Location
    Toledo Ohio
    Posts
    143
    I am not sure how to create this code to only select books that have not been checked out not using the yes/No field. I tried the DLOOKUP using the yes/no field and it does not like that. It seems it has to do with the way I have the tables and the query set up but I am not sure. I watched this video https://www.youtube.com/watch?v=2Kq3jZ73PGQ and did the same and it says error.
    =DLookUp("CheckOut","tblCheckOut","CheckOut=" & [BookName_ID])

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    tblCheckOut is not a table in your image.

    A query that lists books from tblBooks that are not in tblLibrary would be a Find Unmatched query - there is a query wizard for that.

    Also:

    SELECT * FROM tblBooks WHERE NOT ID IN (SELECT BookName_ID FROM tblLibrary);

    So you don't want to keep history of check out/in?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    LaughingBull is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Location
    Toledo Ohio
    Posts
    143
    A book is checked out and when it is checked in I want the record deleted no history
    I will check it out and let you know what happens

    Thank you

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Then you can eliminate a table. Just have the CheckOutDate and CheckOutBy fields in tblBooks. When book is returned set those fields to Null. DueDate can be a calculated value.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 1
    Last Post: 08-18-2014, 07:55 AM
  2. Replies: 2
    Last Post: 04-13-2012, 12:53 AM
  3. Replies: 2
    Last Post: 01-24-2012, 02:16 PM
  4. Replies: 1
    Last Post: 04-29-2010, 05:22 PM
  5. Delete all records in a table?
    By bob646 in forum Access
    Replies: 1
    Last Post: 05-20-2007, 11:41 PM

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