After retrieving data into a recordset object, I want to filter this data. I tried using the objRs.filter method of ADO, but it doesn’t seem to work.
This is my syntax:
objRSEmp.Filter = "EmpName like 'b*'"
EmpName is the name of the field in my SQL table.
I tried using a session variable, but after that I can’t use any of the recordset’s properties through the new variable. Can you help?
Just setting the Filter property doesn’t do it. You then have to set the recordset object to itself or another variable, like so:
objRSEmp.Filter = "EmpName like 'b*'"Set objRSFiltered = objRSEmp
Depending on how big the recordset is, you may want to just do another query from the database. It will probably run faster, especially if you create a stored procedure to do the work for you. Also, make sure you have indexes on the fields that you are using in your filters.