It's completely untested, but you might get away with switching to filtering the recordset instead of index/seek. Something like this but with your variables:

https://docs.microsoft.com/en-us/off...r-property-dao

I guess that would let you keep the changes within the function.