macro to refresh from Access and then

K

klav

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?
 
F

FSt1

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
 
K

klav

Thank you for your help.

FSt1 said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top