The code that performs the validation is before the code that creates the recordset, this means when the validation is performed, the recordset does not exist yet.
the validation code is at lines 7 - 21
the recordset code is at lines 54 - 62, it needs to be moved so that it is before the validation code.