Thanks for your lead - the variable nominated in the COUNT function was not appropriate.
Thanks again for your help.