![]() |
macro to refresh from Access and then
I have a spreadsheet that is linked to an Access query. I am opening this
spreadsheet with a macro. In the macro, I am executing a refresh command and then I need to do some other things with the macro (such as opening other files and grabbing certain cells and putting them in a new spreadsheet). It seems that sometimes the macro continues without the refresh having completed. Is there a way to ensure the macro does not continue until the refresh has finished? |
macro to refresh from Access and then
hi
you are allowing the query to refresh in the background. not recomended for reason you have already found out. would have been nice if you had posted your refresh code but here is the line i use to refresh Sheets("sheet1").range("A1").querytable.refresh backgroundquery:=false adjust the sheet and cell references to suit. you could also use.. sheets("sheet1").select range("A1").select selection.querytable.refresh Backgroundquery:=False but why???? either way will pause code execution untill the refresh is complete. Regards FSt1 "klav" wrote: I have a spreadsheet that is linked to an Access query. I am opening this spreadsheet with a macro. In the macro, I am executing a refresh command and then I need to do some other things with the macro (such as opening other files and grabbing certain cells and putting them in a new spreadsheet). It seems that sometimes the macro continues without the refresh having completed. Is there a way to ensure the macro does not continue until the refresh has finished? |
macro to refresh from Access and then
Thank you for your help.
"FSt1" wrote: hi you are allowing the query to refresh in the background. not recomended for reason you have already found out. would have been nice if you had posted your refresh code but here is the line i use to refresh Sheets("sheet1").range("A1").querytable.refresh backgroundquery:=false adjust the sheet and cell references to suit. you could also use.. sheets("sheet1").select range("A1").select selection.querytable.refresh Backgroundquery:=False but why???? either way will pause code execution untill the refresh is complete. Regards FSt1 "klav" wrote: I have a spreadsheet that is linked to an Access query. I am opening this spreadsheet with a macro. In the macro, I am executing a refresh command and then I need to do some other things with the macro (such as opening other files and grabbing certain cells and putting them in a new spreadsheet). It seems that sometimes the macro continues without the refresh having completed. Is there a way to ensure the macro does not continue until the refresh has finished? |
All times are GMT +1. The time now is 04:13 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com