I would like to say a massive thank you all for your help.

I now have the scipt working perfectly.

Thanks
Mark