Well, when strange things appear to be happening, my thought was to try the search to rule out some possibility of duplicating names.davegri, doesn't quite explain why variable would have correct value in Debug but then following line showed it was empty.
If names are duplicated, who know which the debug.print might be looking at?