This issue is just a bit of code that got placed in the wrong spot. Lines 51-67 have to be below the recordset that ends on line 149.
I moved it for you and the page is functioning properly now. The code I moved is now on lines 133-149 for reference.