title: Delete a table on report close with slight delay
body: <p>I want to keep my database performance at the top, reducing the number of objects and creating stuff just temporarily. I have a table that should be automated from the code: </p>
  
  <p>There is a report that needs data from that table - (works fine), so this is the flow: </p>
  
  <pre><code>'-&gt; form is opened -&gt; onClick find-button 
  '-&gt; table of dates is created -&gt; table of dates is populated 
  '-&gt; Report is opened -&gt; onReportClose (I want the table of dates to be deleted).
  </code></pre>
  
  <p>The code is written, it works fine on its own: </p>
  
  <pre><code>CurrentDb.TableDefs.Refresh
  DoCmd.DeleteObject acTable, "temp-table"
  </code></pre>
  
  <p>So I added a macro on report close to run the above code: which is a function. But I get the error below: </p>
  
  <blockquote>
    <p>Run-time error '3211': The database engine could not lock table
    'temp-table' because it is already in use by another person or
    process.</p>
  </blockquote>
  
  <p>I believe this is because the report is probably using it. So I added a ten seconds delay to my code: </p>
  
  <pre><code>Dim PauseTime As Variant
  Dim Start As Variant
  Dim Elapsed As Variant
  
  PauseTime = 10
  Start = Timer
  Elapsed = 0
  Do While Timer &lt; Start + PauseTime
      Elapsed = Elapsed + 1
  Loop
  CurrentDb.TableDefs.Refresh
  DoCmd.DeleteObject acTable, "temp-table"
  </code></pre>
  
  <p>Instead, It seems to be holding the whole database for 10 seconds and the same issue is still occurring. Any Ideas/suggestions on how to delete this table on report close, or force table delete in Ms-Access (maybe?) or how to work around this are welcomed.</p>