I don't get a compile error and would not attempt to solve this without sample data to allow the routine to run.