Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Macro is too fast for SQL request.

I have a macro which automates my whole spread sheet which consists of
Database references and SQL statements. I have included the macro to update
the
SQL statements before I save the sheet using the current date as a filename.
But I find
that because there is a lag for the SQL request the file is saved without
the current SQL
data. But as soon as I (F9) recalculate the sheet after the macro has
completed it shows the current
data!? I am specifying in the macro to CALCULATE before it saves but this
does not help.
Is there any way to suspend the macro as it runs the SQL update all command?
Even if it is a preset time
since the maximum time to wait for the Request would never be greater than
15s.

Thanks again to all those generous people sharing their experience with us
who are in need.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Macro is too fast for SQL request.

If you are using querytables, then you need to do foreground queries and the
macro will wait for them to complete

Dim qt as QueryTable
for each qt in ActiveSheet.querytables
qt.Refresh BackgroundQuery:=False
Next

--
Regards,
Tom Ogilvy


Rudolphs wrote in message
...
I have a macro which automates my whole spread sheet which consists of
Database references and SQL statements. I have included the macro to

update
the
SQL statements before I save the sheet using the current date as a

filename.
But I find
that because there is a lag for the SQL request the file is saved without
the current SQL
data. But as soon as I (F9) recalculate the sheet after the macro has
completed it shows the current
data!? I am specifying in the macro to CALCULATE before it saves but this
does not help.
Is there any way to suspend the macro as it runs the SQL update all

command?
Even if it is a preset time
since the maximum time to wait for the Request would never be greater than
15s.

Thanks again to all those generous people sharing their experience with us
who are in need.




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how do I write a request to 'Save As' Macro CRAIG K[_2_] Excel Discussion (Misc queries) 5 March 10th 08 01:31 PM
Macro Request: Fill in empty cells with previous Filled cell in column Artis Excel Worksheet Functions 2 June 25th 07 08:30 PM
How to Create an Excel Macro to send a meeting request. DM HD Excel Discussion (Misc queries) 2 February 28th 05 02:39 PM
Password request to run macro Colin Foster[_2_] Excel Programming 4 January 31st 04 08:40 PM
Request password during Protect macro Gavin[_5_] Excel Programming 6 November 11th 03 12:54 PM


All times are GMT +1. The time now is 01:53 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"