Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

make access sleep 1

Status
Not open for further replies.

OhioSteve

MIS
Mar 12, 2002
1,352
US
How do I say "wait for 3 seconds" in VBA for Access 2003?
 
Maybe:
Code:
Sub Wait3Secs()
dteTimeIn = Now()
dteTimeOut = DateAdd("s", 3, dteTimeIn)
Do Until Now() = dteTimeOut
Loop
'Debug.Print dteTimeIn, dteTimeOut
End Sub
 
How do I say "wait for 3 seconds" in VBA
MsgBox "wait for 3 seconds"
Sorry, I couldn't resist.

BTW, Remou, use the DoEvents function inside your loop, unless you want to lock the CPU.
 
PHV [lol]

- here's another probable CPU blocker ...

[tt]' in declaration section
Private Declare Sub Sleep "kernel32" (ByVal dwMilliseconds as Long)

' in the sub where needed
sleep 3000[/tt]

- but - could I ask why? I mean, if you're waiting for a process to finish, there are usually methods to do that too ...

Roy-Vidar
 
Yes I will tell you why Roy.

In the beginning, God created the heavens and the Earth...

Perhaps I should skip forward a bit.

I am writing an application that has two parts: a client and a server. The client is a nifty little Access DB. The server is an asp.net application. The server application is on a web server, the client application is on laptops. I need to write an Access function that does this:

1) Set a value in a table to false.

2) start an invisible instance of IE and opens a web page. This web page has an asp.net function in its on load event.

3) The asp.net function attempts to set the value in the little client DB to true.

4) Then the MS Access function checks that table. It retrieves the value and returns it.

The purpose of this is to determine whether the user can interact with the asp.net application. If the test works, I start moving real data between the client and the server.

After posting yesterday, I found a crude way to make Access wait:

'Give asp.net a few seconds to change the test value.
Dim a As Date
a = DateAdd("s", 10, Now())
Do While a > Now()
Loop

I think that that will paralyze the user's laptop, but it will force Access to wait.
 
Stupid me to ask such question when I know nothing about ASP, well, the initial question was about a2k3, wasn't it;-)

Sooner or later this will barf - the process isn't finished when the next step of the function is performed - so with such "hardcoded waiting", you will need to do some testing/programming to circumvent that.

With other technologies, one could use something like the approaches here faq222-428, thread705-834235 (PHVs and CajunCenturions suggestions), which shells the process and wait for the process to finish. I wouldn't know a thing about if such would work in your setup, but I fear they will not.

Then, I'm wondering - if you automate IE, wouldn't there be some methods there to "catch" this load event? (I know nothing about that, either)

Then there's the method of for instance trying this from a modal form, using it's timer.

The code in the timer event would simply either open a recordset on the table where the Yes/No field resides, and test it, or if you bind the table to the form, test a bound control/recordsource field. I just did a smallish with something like that, which seemed to work on my setup - single computer)

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top