title: Remove and add ID key index from Access table in VBA
body: <p>I have an Access DB to automatically unify several CSV's in one table hourly (<strong>Aux_Table1</strong>) via macro (converted to VBA). Before unification, I run a query to clean <strong>Aux_Table1</strong> table, but Access is coded to <strong>NOT</strong> reuse KEY IDs, so each time I clear and unify CSV's, keys IDs keep counting.</p>
  
  <p>The only method I know to "<em>reset</em>" ID KEY numeration is to delete an create manually this primary key in table's design mode, but I want to run it all automatically (it's part of a huge batch process).</p>
  
  <p>How can I make this process via VBA to INCLUDE in my (VBA) function? (see this 4Mb <a href="http://i.imgur.com/SHi6VJO.gifv" rel="nofollow">GIF</a> demo).</p>
  
  <p>Example of my function: </p>
  
  <pre><code>Function MacroUnify()
      DoCmd.SetWarnings False
      DoCmd.OpenQuery "00_Borrar_Aux_Tabla1", acViewNormal, acEdit
      &gt;&gt;&gt; Here I need to _REMOVE_ PrimaryKey from Aux_Tabla1 &lt;&lt;&lt;
      &gt;&gt;&gt; Here I need to _CREATE_ PrimaryKey from Aux_Tabla1 &lt;&lt;&lt;
      DoCmd.OpenQuery "10_Crea_Tabla definitva", acViewNormal, acEdit
      DoCmd.OutputTo acOutputTable, "zzz_resultado_Combinado", "Excel97-Excel2003Workbook(*.xls)", "D:\access\fullCatalog.xls", False, "", , acExportQualityPrint
  End Function
  </code></pre>
  
  <p>I've tryed with:</p>
  
  <pre><code> CurrentDb.Execute "ALTER TABLE Aux_Tabla1 DROP CONSTRAINT PrimaryIndex"
   DoCmd.RunSQL "CREATE INDEX PrimaryIndex ON Aux_Tabla1(ID) WITH PRIMARY"
  </code></pre>
  
  <p>The function runs without problem, but the key index is still counting without reset.</p>
  
  <p>PS: The index name is <strong>PrimaryIndex</strong> and the field name is <strong>ID</strong></p>