For some reason my posts are not staying in this thread. I posted yesterday to say that I had fiddled around with it and eventually starting afresh with a clean file and typed in the code and it worked! Thanks Erwin! I'm sure my post was here because I saw it before left the thread.
I knew the problem was in something I had in the file. Just couldn't and didn't figure out what it was.
If I want to do this for other forums as well I just repeat the same code directly beneath that one, changing the forumid and threadid as necessary?