title: Access Database not closing after a Macro
body: <p>I have a team of 3 people at work who all use batch files to run Access macros on a regular basis with a command similar to the following:</p>
  
  <pre><code>START "" /min /wait "msaccess.exe" "%TEMP%\Database.accdb" /x Main
  </code></pre>
  
  <p>At the end of all macros called this way, we end them with a QuitAccess (Exit) action. This <strong>usually</strong> ends the Access process and hands control back to the batch file to continue.</p>
  
  <p>The issue is that sometimes after the Macro has finished (we can tell it has finished because exported text/Excel files exist) the Access database doesn't close, meaning that the calling batch file is stuck, waiting for Access to close.</p>
  
  <p>When this occurs, we fix it by going into Task Manager and killing the MSACCESS.EXE process. Then the batch file continues.</p>
  
  <p>There isn't anything we can do at the end of the macro, or afterwards in the batch file, to fix this, because the process is stuck in a state between the macro and the batch file.</p>
  
  <p>Does anyone have any ideas on how to prevent this?</p>