MR Campbell
Board Regular
- Joined
- Aug 2, 2002
- Messages
- 113
Ok ... for some time I have had a puzzling issue with an Excel macro enabled workbook that contains a single SQL query to another database. I cannot stress more that for YEARS it worked with no problems at all. Then one day it just does not work anymore .... the code runs but it does not retrieve the latest data. No error messages are generated, so you are led to thinking that it has updated but it hasn't updated the data at all. The only way I can get it to work now is to physically click on Data then click on the REFRESH ALL. This workbook only has ONE query to a database.
This is the code I used for years (then one day in 2016 it did not work .. no error message at all):
Sheets("Data").Range("a2").QueryTable.Refresh BackgroundQuery:=False
Then I tried this and it worked for a while (this was obtained from the macro recorder):
ActiveWorkbook.Connections("Query from SynergyOne").Refresh
This failed (still no error message ... it just didn't do anything).
Then I tried (this worked for about 6 months)
ActiveWorkbook.RefreshAll
This worked up until July 2016.
So at the moment to get the workbook to execute the refresh of the query, I have to physically click on REFRESH ALL. I would be extremely grateful to anyone who can shed some light on this problem.
This is the code I used for years (then one day in 2016 it did not work .. no error message at all):
Sheets("Data").Range("a2").QueryTable.Refresh BackgroundQuery:=False
Then I tried this and it worked for a while (this was obtained from the macro recorder):
ActiveWorkbook.Connections("Query from SynergyOne").Refresh
This failed (still no error message ... it just didn't do anything).
Then I tried (this worked for about 6 months)
ActiveWorkbook.RefreshAll
This worked up until July 2016.
So at the moment to get the workbook to execute the refresh of the query, I have to physically click on REFRESH ALL. I would be extremely grateful to anyone who can shed some light on this problem.