I've been struggling trying to find a way to pause things in an Access database. I've found many suggestions and some of them work, but not the way I want.
I've created a mini-example to see if I can get it to work (then I'll use it in the real program).
There are two Forms (Form1 and Form2). When I click on a button on Form1 it closes Form 1 and opens Form2. There is a button on Form2 that when clicked on does do what I need (pauses for 5 seconds). Here is the code I'm using....
Module code:
Sub WaitFor(NumOfSeconds As Long)
Dim SngSec As Long
SngSec = Timer + NumOfSeconds
Do While Timer < SngSec
DoEvents
Loop
End Sub
Command Button Code:
Call WaitFor(5)
MsgBox "Waited for 5 seconds", vbOKOnly
DoCmd.Close
DoCmd.OpenForm "Form1", acNormal
I need the code in the button on Form2 to run without a user needing to click on it. I've tried putting that code in a number of the Form events with no luck, sort of. Depending on which event it goes in it does "work" but Form2 is never actually visible on the screen.
I've tried calling the Command Button on Form2 from various events (Load, Activate, Current, Got Focus). When it does work I still have the problem where Form2 is never visible on the screen.
Any suggestions? (A Timer control like Visual Basic has would be nice!)