Results 1 to 6 of 6
  1. #1
    shylock is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Sep 2018
    Location
    Dayton, Ohio
    Posts
    100

    Delete Temporary table

    I am trying to delete a temporary table but get an error when executing DoCmd.DeleteObject actable, "TempServicetbl". The error is: "Run-time error '3211':: The database engine could not lock the table 'TempServiceTbl' because it is already in use by another person or process."



    Since I am the only person using it, it must be another process but the only application using it is the one I'm trying to exit. I want to "clean up" before exiting so that the next time the application runs it will create a 'fresh' temporary table. How can I release the lock on this table so it can be deleted? Does it really need to be deleted or will the next iteration over-write the temp table with a new one? I think it probably will, but is that the proper thing to do?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,643
    I think it will get over-written, but personally I wouldn't delete/create it, I'd empty it and populate it.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,129
    Agree that there is no need to delete it as it would be overwritten.
    Also agree with just emptying and repopulating...but both methods will cause your file size to increase by a similar amount and the latter method may be slightly slower.

    The fact that you can't delete the temp table suggests a recordset or query based on that process is still in use.
    After use always set recordsets to nothing
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,643
    I tested that line on a table in a test db that wasn't opened or accessed in any way, got that same error.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,372
    As did I - no error and table was deleted.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,643
    I'm a dope. The test form I used had a hidden subform pointing to that table.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Sharing temporary table data
    By LonghronJ in forum Modules
    Replies: 13
    Last Post: 06-18-2018, 12:21 PM
  2. VBA To Add Primary Key To Temporary Table
    By lccrews in forum Programming
    Replies: 4
    Last Post: 05-25-2018, 12:38 PM
  3. Replies: 5
    Last Post: 01-10-2018, 04:16 PM
  4. Create a temporary Table from Query
    By WickidWe in forum Queries
    Replies: 1
    Last Post: 12-11-2013, 07:19 AM
  5. Replies: 11
    Last Post: 04-04-2012, 05:48 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