I have a requirement for query with parameters to get data from MS SQL 2005 db. Apparently, one cannot use the OLEDB driver and the Connection Properties box, so I'm writing a macro to collect the parameters from Sheet2 and output data to Sheet1.
When Sheet1 is blank, the following works like a charm. Once the data has been retrieved though, the consequent executions of the macro just add columns with data.

Before having added the qt.Delete statement, I had a condition of trying to refresh the qt, which didn't work, so I guess the only means to refresh the data is to re-create the qt every time the macro runs, which seems extremely inefficient.

So I guess I'd like to find out answers to the following questions:
1) Is there a way to actually refresh a QueryTable that was based on a recordset by changing the recordset and just perform the .Refresh method (without constantly doing the .Add)?
2) If not, what's the best mechanism of doing the "refresh"?

Thank you,
Sergey

Please Login or Register  to view this content.