Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default MS Query refreshing in order

I have written an excel spreadsheet that uses many query's to get info from
an Access db. In some cases, a query uses the results from another query as
parameters. I have set up a macro that refreshes each table separately using
a For...Next loop to refresh each Querytable within each sheet. My thought
was that by running the queries in order, the results would be back on the
first queries before the second queries run. In each case, the spreadsheets
do not update until all the query defs run. I have tried putting a wait
command in and turning on and off screen updating. I am hoping to avoid
using the "Update query when Cell changes" option. Any thoughts?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default MS Query refreshing in order

for each qt in Activesheet.QueryTables
qt.Refresh BackgroundQuery:=False
Next

--
Regards,
Tom Ogilvy


"billybob" wrote:

I have written an excel spreadsheet that uses many query's to get info from
an Access db. In some cases, a query uses the results from another query as
parameters. I have set up a macro that refreshes each table separately using
a For...Next loop to refresh each Querytable within each sheet. My thought
was that by running the queries in order, the results would be back on the
first queries before the second queries run. In each case, the spreadsheets
do not update until all the query defs run. I have tried putting a wait
command in and turning on and off screen updating. I am hoping to avoid
using the "Update query when Cell changes" option. Any thoughts?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default MS Query refreshing in order

This is what I currently have in my code. I run through this for each sheet
in my workbook. The issues is that it does not seem to update the
spreadsheet until after all the pages have been updated. Because subsequent
queries use the previous queries data as parameters, they are not being
updated properly.

Example:
Sheet1 has query a which loops throught the querytable.refresh first
Sheet 2 has query b which uses the results in Sheet1 as parameters. The
for...next loop for sheet2 is after the one for sheet 1, but the parameters
are not being updated until after the macro is complete.

Thanks,
JS

"Tom Ogilvy" wrote:

for each qt in Activesheet.QueryTables
qt.Refresh BackgroundQuery:=False
Next

--
Regards,
Tom Ogilvy


"billybob" wrote:

I have written an excel spreadsheet that uses many query's to get info from
an Access db. In some cases, a query uses the results from another query as
parameters. I have set up a macro that refreshes each table separately using
a For...Next loop to refresh each Querytable within each sheet. My thought
was that by running the queries in order, the results would be back on the
first queries before the second queries run. In each case, the spreadsheets
do not update until all the query defs run. I have tried putting a wait
command in and turning on and off screen updating. I am hoping to avoid
using the "Update query when Cell changes" option. Any thoughts?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default MS Query refreshing in order

So you are already using the backgroundquery:=False parameter?


If so, then you can try adding a doevents

For each sh in Worksheets
for each qt in sh.QueryTables
qt.Refresh BackgroundQuery:=False
doevents
Next
Next

--
Regards,
Tom Ogilvy


"billybob" wrote:

This is what I currently have in my code. I run through this for each sheet
in my workbook. The issues is that it does not seem to update the
spreadsheet until after all the pages have been updated. Because subsequent
queries use the previous queries data as parameters, they are not being
updated properly.

Example:
Sheet1 has query a which loops throught the querytable.refresh first
Sheet 2 has query b which uses the results in Sheet1 as parameters. The
for...next loop for sheet2 is after the one for sheet 1, but the parameters
are not being updated until after the macro is complete.

Thanks,
JS

"Tom Ogilvy" wrote:

for each qt in Activesheet.QueryTables
qt.Refresh BackgroundQuery:=False
Next

--
Regards,
Tom Ogilvy


"billybob" wrote:

I have written an excel spreadsheet that uses many query's to get info from
an Access db. In some cases, a query uses the results from another query as
parameters. I have set up a macro that refreshes each table separately using
a For...Next loop to refresh each Querytable within each sheet. My thought
was that by running the queries in order, the results would be back on the
first queries before the second queries run. In each case, the spreadsheets
do not update until all the query defs run. I have tried putting a wait
command in and turning on and off screen updating. I am hoping to avoid
using the "Update query when Cell changes" option. Any thoughts?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Refresh order when refreshing all in a workbook Michael Pan Excel Discussion (Misc queries) 1 September 17th 09 05:57 AM
Refreshing Web Query Problem andym Excel Programming 2 December 18th 05 06:57 PM
Help! Query Refreshing Emma Hope Excel Programming 2 September 19th 05 05:28 PM
Parameter Query not refreshing. MER Excel Programming 3 May 26th 05 09:15 PM
get new file name when refreshing query gaba Excel Programming 0 November 12th 04 05:54 PM


All times are GMT +1. The time now is 08:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"