You moved it into the wrong repeat region... it should be just after line 546.
I don't see the where clause or parameter in the recordset at all, so I can't comment on what was wrong with it in your tests... but it sounds like you may not have typed in the correct parameter name to match the placeholder in the SQL when you added it.