Forum Discussion
PowerBI_Query
4 years agoHelper II
Background Query Completion
I have created a VBA code to import data from CSV convert it into a table and refresh the query that is already setup. I want the user to be informed when the background query is completed by displa...
- 4 years ago
Posted the question on VBA forum and got the below solution it works flawless.
With ThisWorkbook For Each objConnection In .Connections 'Get current background-refresh value bBackground = objConnection.OLEDBConnection.BackgroundQuery 'Temporarily disable background-refresh objConnection.OLEDBConnection.BackgroundQuery = False 'Refresh this connection objConnection.Refresh 'Set background-refresh value back to original value objConnection.OLEDBConnection.BackgroundQuery = bBackground Next 'Save the updated Data '.Save End With MsgBox "Completed"
PowerBI_Query
4 years agoHelper II
Posted the question on VBA forum and got the below solution it works flawless.
With ThisWorkbook
For Each objConnection In .Connections
'Get current background-refresh value
bBackground = objConnection.OLEDBConnection.BackgroundQuery
'Temporarily disable background-refresh
objConnection.OLEDBConnection.BackgroundQuery = False
'Refresh this connection
objConnection.Refresh
'Set background-refresh value back to original value
objConnection.OLEDBConnection.BackgroundQuery = bBackground
Next
'Save the updated Data
'.Save
End With
MsgBox "Completed"
jbwtp
4 years agoMemorable Member
Hi PowerBI_Query,
Well done!
Sorry, misunderstood the requirements. The code that you've posted is not running queries in the background, therefore the user would not be able to do anything until it is completed. My initial thought was that you want the query to run in the background while the user is working on something else and notify once completed to track their attention.
Cheers,
John
N.B. Could you please mark your last post as asolution to close the topic and help others to find answers for a similar problems?