Results 1 to 4 of 4
  1. #1
    neuk is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    May 2019
    Posts
    36

    Count the number of records deleted and then fire a sub routine


    I would like to count the number of records deleted and then fire a sub routine to perform an action based on the count. The problem is that the on delete event fires for each record selected, so I don't have a way of knowing when to fire the routine. I'm in datasheet view and I'd prefer not to change this to a continuous form or write a special delete procedure based on a button.

    Initially I thought to create a collection from the on delete event and then pass the collection into the module from the After Del Confirm event. Sadly I noticed the After del confirm event fires before, not after, the on delete event. Any thoughts? I'd just like the ids from the deleted records and fire another routine with that information accessible immediately after.

  2. #2
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,114
    Have a look at this thread, it should give you the info you need:
    https://stackoverflow.com/questions/...d-from-subform
    Please post back with your attempt if you get stuck.
    Cheers,
    Vlad
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  3. #3
    neuk is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    May 2019
    Posts
    36
    Yeah. I was afraid of that...but then the thought occurred to me, why do I even need to make the collection? Why don't I just write a function and loop through the function, with the current value, each time the delete event fires? Brilliant. Seems to work just fine. Thanks Vlad. You're a genius.

  4. #4
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,114
    Don't know about that , but glad you solved it!
    Cheers,
    Vlad
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

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

Similar Threads

  1. Count number of records <=4 hours
    By jbeets in forum Queries
    Replies: 6
    Last Post: 05-14-2020, 10:16 PM
  2. Count number of records
    By udigold1 in forum Queries
    Replies: 5
    Last Post: 02-28-2018, 08:37 AM
  3. Replies: 1
    Last Post: 01-24-2013, 05:50 PM
  4. Replies: 6
    Last Post: 07-25-2011, 01:54 PM
  5. count the number of records from a query
    By Nixx1401 in forum Queries
    Replies: 4
    Last Post: 05-24-2011, 06:45 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