Thanks rory, actually your code is what I was looking for.

Thanks to royuk also for his help and support.