do you check the recordset returned to see if it is not an empty recordset?
afaik it will only return any records if there is an exact match to the parameter
so the most it will return is 1 record

Count = rs("MaxCode") + 1
i have no idea what is in field maxcode, but it does not seem, to me, relevant to this operation, i would assume it would always be 0, empty or null, which is why each new name is added with 001