title: Deleting data from Access with VBA
body: <p>I'm trying to delete every record from my current Access database in VBA where <code>OTP = txtOTP.value</code> and <code>VARIABLE = {NomAdminContrats,TelAdminContrats,TelecAdminContrats, [...]}</code></p>
  
  <p>Here is my code:</p>
  
  <pre class="lang-vb prettyprint-override"><code>Dim query As Recordset 
  Set query = CurrentDb.Execute("DELETE * FROM tb_SOMMAIRE WHERE OTP = '" &amp; txtOTP.value &amp; "' AND (VARIABLE = 'NomAdminContrats' or VARIABLE = 'TitreAdminContrats' or VARIABLE = 'UnitAdminContrats' or VARIABLE = 'AdrAdminContrats' or  VARIABLE = 'VilleAdminContrats' or VARIABLE = 'TelAdminContrats' or VARIABLE = 'TelecAdminContrats' or VARIABLE = 'CourrielAdminContrats')")
  </code></pre>
  
  <p>I got an error 3219 Invalid Operation when trying with OpenRecordset or <em>Expected function</em> when trying with Execute. I've tried a lot of things but I didn't manage yet to get this query working. I also have the full table in a recordset, would it be easier/faster to do it with myRecordset.Delete? If so, how could I do it?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Now trying with CurrentDb.Execute instead of CurrentDb.OpenRecordset. The error is now <em>Function expected</em> instead of <em>Invalid Operation</em>.</p>