I've finally got it working by the horrible expedient of setting a boolean property when it is triggered, using that to jump out of the sh1t code, then doing what needed to be done instead, then unsetting it when it returned..

The problem lay in the fact that the same report is being used by two different mechanisms and they were sharing code, and somewhere in there it was going wrong. I'm not happy with what I've done, but at least it is working now. One day I'll have to totally rewrite it, no doubt, but today is not that day.

Thanks to all, but it was Sam who pointed me in the direcction that worked.