Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

query table in excel not refreshing

Posted on 2014-11-17
5
Medium Priority
?
158 Views
Last Modified: 2014-12-06
I have an excel workbook that is connected to an access query that imports the access data into one of my worksheets as a table. I have a vba script that auto opens this worbook, and tells it to refresh all contents including the query table and the other worksheets that have formulas dependent in the query table. When i run the speeadsheet manually, the query imports perfectly. But when the spreadsheet is auto run from the task manager, the query table doesnt update fast enough before the rest of the vba code proceeds and closes the worbook.  I tried disabling background refresh in the excel data connection options, and tried adding some code in vba sucha as DoEvents, application.refreshall, etc but still doesnt help.

Can someone provide some vba code that calls the query object and then validate that the refresh is completed for that specific query? Lets say my workbook is called worbook1.xlsm, the query table is called query1table, and query1table is located on sheet2.  I see this is a common problem, but i havent found a solution yet.
0
Comment
Question by:jtencha
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 23

Expert Comment

by:Michael Fowler
ID: 40448976
Try

Application.CalculateUntilAsyncQueriesDone

after calling the refresh command

http://msdn.microsoft.com/en-us/library/office/ff821008(v=office.15).aspx
0
 

Author Comment

by:jtencha
ID: 40451222
Thanks. I tried that also, didnt help. Is there querytable property that can be verified that refresh is complete, and continhe reading the rest of my code? Btw, the code is auto launched from a private sub from  'this worbook' module.
0
 
LVL 23

Accepted Solution

by:
Michael Fowler earned 1500 total points
ID: 40451272
Is this what you are after

QueryTable.Refreshing Property
http://msdn.microsoft.com/en-us/library/office/ff834459(v=office.15).aspx
0
 

Author Comment

by:jtencha
ID: 40453022
ok, will try that, will let you know how it goes
0
 

Author Closing Comment

by:jtencha
ID: 40485049
thanks
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question