Hi JHB
Below is the code I modified and its working, Thanks for your help.
I have one more problem, The macro is taking too much time in getting connection, is their a way to make it faster
Option Explicit
Function CreateAndRunQuery()
Dim con As Object
Dim rs...