title: How to delete a table if it exists?
body: <p>I use MS Access macros and queries to build my application.   I use some temporary import files, and need to either run a macro, or some VBA, to test if they exist, and then if they do, to delete them.</p>
  <p>My table name is &quot;TempImport1&quot;</p>
  <p>I've researched this via Google searches and have some VBA that might work. I have cut/pasted VBA code under a button in the past, and it worked, but not this time. How do I put the code into a module or a click sub button?</p>
  <pre><code>Function IsTable(sTblName As String) As Boolean
      'does table exists and work ?
      'note: finding the name in the TableDefs collection is not enough,
      '      since the backend might be invalid or missing
  
      On Error GoTo TrapError
      Dim x
      x = DCount(&quot;*&quot;, sTblName)
      IsTable = True
      Exit Function
  TrapError:
      Debug.Print Now, sTblName, Err.Number, Err.Description
      IsTable = False
  
  End Function
  </code></pre>