Results 1 to 2 of 2
  1. #1
    justinr12345 is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2018
    Posts
    7

    Access Error Event only hits once when deleting multiple records with referential integrity errors

    I have Datasheet tables in Forms that tracks record level changes, inserts, and deletes to an Audit table. Heres my current scenario.
    User deletes multiple records, lets say 4 records. If the first 3 are good to be deleted (as in no referential integrity rules are being violated) and the last has a referential integrity error here are the order of events: Delete Event for each of the 3 good records, Delete event for bad record, Error Event for bad record, BeforeDelConfirm, then AfterDelConfirm. This works properly as the Delete Event loads the Audit statements for all 4 records into a temp table, then the Error Event removes the records for the 1 bad row, then the BeforeDelConfirm asks to confirm, and the AfterDelConfirm pastes the 3 sets of Audit records to the Audit table. HOWEVER, if we take the scenario where the user deletes 4 records, the first 2 are good and the last 2 have referential integrity errors, the order of events is as follow: Delete Event for 2 good records, Delete event for 1st bad record, Error Event for 1st Bad Record, Delete Event for 2nd Bad Record, BeforeDelConfirm, AfterDelConfirm. The issue is the Error Event doesnt run for any records but the first, so how can I catch the records values to prevent it from going to the Audit table? I would prefer if it would be able to only delete the records able to be deleted(i.e. no referential integrity errors), and I would hate to have to prevent all records from being deleted if more than one error exists(in which case I would probably just prevent any deletions even if one error just so I dont have an extra confusing rule for my end user.)

  2. #2
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,793
    Might help us more if you post your code, using code tags (# on menubar).
    If you are using the Form Delete event and incorporate error handling, IIRC this event should cycle for each record being deleted, and if it can't, it would raise an error (3379?). In that case, you should be able to branch one way for no error, and the other when it errs. Not sure what that would be; I can't tell if it would just be a Cancel for the deletion, or some other operation on the record.

    I guess you just can't let Access delete what it can and trap the usual error message for those it can't? Not sure I'm following your posted procedure. If you're moving records to another table as a form of deletion, why not just flag the record in the original table somehow, as in a yes/no field or DateDeleted field?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Referential integrity
    By Lou_Reed in forum Access
    Replies: 14
    Last Post: 12-17-2015, 03:08 PM
  2. Replies: 3
    Last Post: 07-17-2013, 08:28 PM
  3. Referential Integrity
    By YunqHero in forum Forms
    Replies: 4
    Last Post: 12-17-2012, 05:05 PM
  4. Referential Integrity
    By Paul H in forum Database Design
    Replies: 3
    Last Post: 11-14-2011, 03:07 PM
  5. referential integrity
    By askjacq in forum Database Design
    Replies: 1
    Last Post: 10-14-2011, 03:23 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