the problem is code order.
the code to perform the validation is at lines 14 - 30.
the code that creates the recordset is at lines 31 - 117.
those code blocks need to be switched around so that the recordset exists when the validation tries to use it.