I changed the value of recordset.CursorLocation from the default adUseServer to adUseClient and that solved my problem.