I can't see anything wrong...are you sure the value of @rptNum is on the database?