Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default ODBC takes time to update

Hello,

I have a macro that connects to an orocale database with ODBC and
passes the database a query and the result is that data is pasted into
excel. I then take that pasted data and do all sorts of stuff with
it.

The problem is that the data takes a few (perhaps 2) seconds to appear
in the excel spreadsheet as the connection to the database is verified
and the data retrieved and then the spreadsheet 'refreshed' (?). This
is a problem because the macro runs faster than the database
connection so by the time the macro has executed the data retrieve
code and is on to the data maniluplation code there is no data to work
with and it errors out.

I have got around this by having two macros - the first pulls down the
data and then the second, when i run it manually with a button a few
seconds later, does the stuff with the data but I would liek to
combine this into one macro.

How can I make excel wait until the data has been downloaded? I have
tried to use the wait() command but that seems to put all of excel on
hold (including the data dump sequence - even if i insert the wait()
command after the data should have been successfully dumped into the
sheet).

I guess that i could use a do until loop like this (in psuedo code)

Do until (timer circuit breaker = true) or isempty(activecell.value) =
false
if the loop has run for 10 seconds then there is a problem there
timer circuit breaker = true
loop

Doesnt seem like a very elegant soln.

Help much appreciated.

thank you

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default ODBC takes time to update

The query has a backgroundquery property. Set it to false and the code will
wait for the query to finish. It is a property of the querytable object.

--
Regards,
Tom Ogilvy


"kaiser" wrote:

Hello,

I have a macro that connects to an orocale database with ODBC and
passes the database a query and the result is that data is pasted into
excel. I then take that pasted data and do all sorts of stuff with
it.

The problem is that the data takes a few (perhaps 2) seconds to appear
in the excel spreadsheet as the connection to the database is verified
and the data retrieved and then the spreadsheet 'refreshed' (?). This
is a problem because the macro runs faster than the database
connection so by the time the macro has executed the data retrieve
code and is on to the data maniluplation code there is no data to work
with and it errors out.

I have got around this by having two macros - the first pulls down the
data and then the second, when i run it manually with a button a few
seconds later, does the stuff with the data but I would liek to
combine this into one macro.

How can I make excel wait until the data has been downloaded? I have
tried to use the wait() command but that seems to put all of excel on
hold (including the data dump sequence - even if i insert the wait()
command after the data should have been successfully dumped into the
sheet).

I guess that i could use a do until loop like this (in psuedo code)

Do until (timer circuit breaker = true) or isempty(activecell.value) =
false
if the loop has run for 10 seconds then there is a problem there
timer circuit breaker = true
loop

Doesnt seem like a very elegant soln.

Help much appreciated.

thank you


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default ODBC takes time to update

On Jun 12, 8:09 pm, Tom Ogilvy
wrote:
The query has a backgroundquery property. Set it to false and the code will
wait for the query to finish. It is a property of the querytable object.

--
Regards,
Tom Ogilvy



"kaiser" wrote:
Hello,


I have a macro that connects to an orocale database with ODBC and
passes the database a query and the result is that data is pasted into
excel. I then take that pasted data and do all sorts of stuff with
it.


The problem is that the data takes a few (perhaps 2) seconds to appear
in the excel spreadsheet as the connection to the database is verified
and the data retrieved and then the spreadsheet 'refreshed' (?). This
is a problem because the macro runs faster than the database
connection so by the time the macro has executed the data retrieve
code and is on to the data maniluplation code there is no data to work
with and it errors out.


I have got around this by having two macros - the first pulls down the
data and then the second, when i run it manually with a button a few
seconds later, does the stuff with the data but I would liek to
combine this into one macro.


How can I make excel wait until the data has been downloaded? I have
tried to use the wait() command but that seems to put all of excel on
hold (including the data dump sequence - even if i insert the wait()
command after the data should have been successfully dumped into the
sheet).


I guess that i could use a do until loop like this (in psuedo code)


Do until (timer circuit breaker = true) or isempty(activecell.value) =
false
if the loop has run for 10 seconds then there is a problem there
timer circuit breaker = true
loop


Doesnt seem like a very elegant soln.


Help much appreciated.


thank you- Hide quoted text -


- Show quoted text -


Great! Thanks for the help

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
Update database from ODBC query (or another method) Richard Edwards Excel Worksheet Functions 4 June 24th 08 11:47 AM
Update database from ODBC query Richard Edwards Excel Discussion (Misc queries) 0 June 24th 08 09:22 AM
MS Query takes along time to open TonyL Excel Worksheet Functions 0 April 6th 06 01:44 PM
Get time it takes to run program!! cjsasl Excel Programming 8 November 11th 05 09:32 PM
How do I update a ODBC query in Excel using pivotTables in VBA? FCS Excel Programming 6 November 10th 05 04:47 PM


All times are GMT +1. The time now is 08:53 AM.

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

About Us

"It's about Microsoft Excel"