Hi,
Yes that was the problem i hadn't declared the variables and set the database as you said. I have got it working in a test database, now to set it up in the main one. Fingers crossed i'll manage that one on my own, lol. Thanks for your help with this, it is going to be so useful.
Jon