End a BackgroundQuery of a ListObjects SQL Query?

Dan DeHaven

New Member
Joined
Aug 26, 2009
Messages
45
I'm using Excel 2010 to pull data via a Worksheets ListObjects with an ODBC connection to a SQL Server. I haven't had problems with this till I ran into an empty record set. In the case of no records Excel continues to Refresh the external query and displays this in the bottom left corner of the app, indefinitely. While it can be ended by closing the UserForm I'd rather add code that does this if the record set is empty.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
<o:p></o:p>
Any thoughts?<o:p></o:p>
 
I believe I've found a solution to the issue.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
<o:p></o:p>
The "BackgroundQuery" property of the ODBCConnection needs to be set to "False". Once this has been done, either by code or manually in the QueryTable Connections dialog, the problem of the endlessly refreshing query goes away.<o:p></o:p>
<o:p></o:p>
I originally tried to do this mid-code in an If statement when the record set contained no records, but this approach didn't work.<o:p></o:p>
<o:p></o:p>
Rather, by setting the property before the refresh has begun seems to be the only way to control the behavior.
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top