title: How do I copy and filter a DAO recordset in VBA?
body: <p>Due to problems with DAO (see <a href="https://stackoverflow.com/questions/7100372/undefined-function-when-using-dao-querydef-in-vba">my previous question</a>), I need to create an Excel VBA Recordset from an Access query and filter its results using a user-defined function.</p>
  
  <p>I thought I could use the following code to accomplish this:</p>
  
  <pre><code>Sub test()
  
  Dim db As Database
  Dim rs As Recordset
  Dim rs_clone As Recordset
  
  Set db = OpenDatabase(dbPath)
  Set rs = db.OpenRecordset("select testVal from dataTable")
  Set rs_clone = rs.Clone
  rs_clone.MoveLast
  rs_clone.MoveFirst
  while not rs_clone.eof
   if myUDF(rs_clone!testVal) then
      rs_clone.delete
   end if
   rs_clone.moveNext
  wend
  
  End Sub
  </code></pre>
  
  <p>But that actually deletes values from my source table, so the clone isn't a new recordset that I can freely alter, it's just another pointer to the original one.  How can I use my UDF to filter out the records I don't want, while leaving the original data untouched, if putting the UDF in the query itself is not an option?</p>