Method to pause VBA?

  • Thread starter Thread starter tkstock
  • Start date Start date
T

tkstock

I must apologize - I'm trying to use this in Access - I was hoping tha
whatver worked for VBA in Excel would work for Access also, but
didn't realize that the Application object for the wait method onl
applied to Excel.

I don't suppose you would happen to know a method for Access?

Thanks
 
tkstock

There's probably a better way, but until you find it you can use this

Dim dtStart As Date

dtStart = Now

Do
Loop Until Now > dtStart + TimeSerial(0, 0, 10)
 
...
Dim dtStart As Date

dtStart = Now

Do
Loop Until Now > dtStart + TimeSerial(0, 0, 10)

You'd want a DoEevnts in there.
There's probably a better way

Yer tiz <g>:

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
....
Sleep 10000

Jamie.

--
 
Jamie Collins said:
...


You'd want a DoEevnts in there.

Why is that? I see that all the time, but I'm not really trying to do
anything here, so I'm not sure why I need it. Just curious.
Yer tiz <g>:

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
...
Sleep 10000

I need to start blogging these API calls. I guess I'll have to learn a few
first.

Thanks,
 
Dick Kusleika said:
Why is that? I see that all the time, but I'm not really trying to do
anything here, so I'm not sure why I need it. Just curious.

Ever find yourself waiting for a application to finish a long process,
so you decide to switch to another app while you're waiting but you
can't because that long process is hogging all the machine's
resources? If that app did the equivalent of a DoEvents every now and
again the OS would do a better job of sharing.

That said, on reflection the loop above will be called thousands of
times in ten seconds so calling DoEvents on each iteration is probably
excessive.

I'd consider the Sleep API to be the best solution because for the
duration the application should take no extra resources.

Jamie.

--
 
Jamie Collins said:
Ever find yourself waiting for a application to finish a long process,
so you decide to switch to another app while you're waiting but you
can't because that long process is hogging all the machine's
resources? If that app did the equivalent of a DoEvents every now and
again the OS would do a better job of sharing.

Oh, "other" applications. That makes sense.
That said, on reflection the loop above will be called thousands of
times in ten seconds so calling DoEvents on each iteration is probably
excessive.

I'd consider the Sleep API to be the best solution because for the
duration the application should take no extra resources.

Concur. Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top