Thank you very much for your reply earlier.
I am trying now to follow your advice. I have added the code but on the following statement it prompts as "Compile error, can't find object or liberary".
dim qdf1 as dao.querydef
As I do not have enough knowledge of VB codes, can you suggest any...