MrExcel Message Board


Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Mar 30th, 2004, 03:31 PM   #1
LAS
 
Join Date: Oct 2002
Posts: 214
Default Sql on closing Excel

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.
__________________
Regards

Lawrence Swartz
www.file-man.com
LAS is offline   Reply With Quote
Old Mar 30th, 2004, 03:46 PM   #2
Juan Pablo González
MrExcel MVP
 
Join Date: Feb 2002
Location: Bogota, Colombia
Posts: 11,738
Default Re: Sql on closing Excel

Uncheck the 'Background Query' property of the query.
__________________
Regards,

Juan Pablo González
http://www.juanpg.com
Juan Pablo González is offline   Reply With Quote
Old Mar 30th, 2004, 03:57 PM   #3
LAS
 
Join Date: Oct 2002
Posts: 214
Default

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
It seems to skip over the AcademicPopulate module and only run the next procedure (RemoveCustMenu).

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?
__________________
Regards

Lawrence Swartz
www.file-man.com
LAS is offline   Reply With Quote
Old Mar 30th, 2004, 04:24 PM   #4
LAS
 
Join Date: Oct 2002
Posts: 214
Default

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.
__________________
Regards

Lawrence Swartz
www.file-man.com
LAS is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT +1. The time now is 06:35 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
All contents Copyright 1998-2009 by MrExcel Consulting.