SQL query in ado work fine only if the Sect column present in ADODC1 sheet.
If the ADODC1 sheet not have Sect column it throws error.
Pls correct my below query…
strSQL = "Select Name,Dept,IIF(ISNULL(Sect),'',Sect) AS Sect from [Adodc1$] UNION Select Name,Dept,Sect from [Adodc2$];"
If the Sect column not present in ADODC1 Sheet, need the results as empty.
What you mean by “need the results as empty”. If you fail over the error you will get a closed recordset. Is that ’empty’?
I suspect this is what you need to do (pseudo code):