title: Access 2010 Query Execution Crash
body: <p>In Windows 10 and MS Access 2010, I am running a vba function that executes a SQL query extracting records from a linked a table that is linked to Outlook.
  The query looks like this:</p>
  
  <pre><code>select * from  where LinkedTable.Field1 like '*string1*' and (LinkedTable.Field2 like 'string2*' OR LinkedTable.Field2 like 'string3*' OR LinkedTable.Field2 like 'string4*' OR LinkedTable.Field2 like 'string5*' OR LinkedTable.Field2 like 'string6*' OR LinkedTable.Field2 like string7*')
  </code></pre>
  
  <p>Before executing the query, I am refreshing the link to the table.</p>
  
  <p>Access is crashing when running the function. Debugging leads to identifying the point of executing the query is when Access is crashing: <code>Set rs2 = db.OpenRecordset(strQ)</code></p>
  
  <p>Here is the code:</p>
  
  <pre><code>    Sub xyz()
      Dim db As DAO.Database
      Dim rs2 As DAO.Recordset 'this the sql query table
      dim rs1 as DAO.Recordset
  set rs1=db.openrecordset("anothertable")
  rs1.movefirst
  do while not rs1.eof 
  
      strQ ="select * from  LinkedTable where LinkedTable.Field1 like '*string1*' and (LinkedTable.Field2 like 'string2*' OR LinkedTable.Field2 like 'string3*' OR LinkedTable.Field2 like 'string4*' OR LinkedTable.Field2 like 'string5*' OR LinkedTable.Field2 like 'string6*' OR LinkedTable.Field2 like string7*')"
  
      db.TableDefs(LinkedTable).RefreshLink
      Set rs2 = db.OpenRecordset(strQ)
      .
  
  rs2.close
  set rs2=nothing
  rs1.movenext
  loop
      .
      .
      En
  </code></pre>
  
  <p>d sub</p>
  
  <p>I noticed that the memory usage goes up every time the statement
  Set rs2 = db.OpenRecordset(strQ)</p>
  
  <p>is executed even though I am cleaning up. It is not released after cleaning up. What potential memory leak can this statement cause?</p>
  
  <p>Thank you.</p>