try opening a query in design view, making the query in there and testing it to make sure it works then when it does go to SQL view and grab that and move it across VBA.
Alternatively paste your vba into the immediate window like sql = "Select UKmai.... etc" then ?ssql to get the query info and...