![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Join Date: Oct 2002
Posts: 214
|
I am runing an update query from excel to a sql database.
The query runs correctly when run BUT, I also run the query when the workbook closes. At that point I get the following Excel message: 'The action will cancel a pending Refresh Data Command. Continue?' If select OK the query does not complete, nor does it run if I cancel. Any ideas how to stop excel from closing the workbook until the query / code has finished running? Thanks fro your help. |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Bogota, Colombia
Posts: 11,738
|
Uncheck the 'Background Query' property of the query.
|
|
|
|
|
|
#3 |
|
Join Date: Oct 2002
Posts: 214
|
Thanks for the fast reply.
It didn't help. I have the following code that runs when closing the workbook: Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
AcademicPopulate
RemoveCustMenu
End Sub
If I step through it (F8) all runs OK but when closing the workbook it doesn't seem to run the first procedure. Any further ideas? |
|
|
|
|
|
#4 |
|
Join Date: Oct 2002
Posts: 214
|
My sincere appologies. I found my bad code.
I changed sheets in the middle of the code which resulted in me exiting the procedure. Sorry to bother everyone. |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|