|  

» Execute Command/Sub-Procedure Using Timer in VBA

This example demostrates how to use a timer to call up a sub procedure after a specific set time has passed.

TimeValue Function is used.

In this example, 3-seconds is assigned to the function.
The Application.OnTime alertTime statement is used to call up the sub procedure, msg, when 3-seconds is up.

Sub timerMsg()
Dim alertTime
MsgBox "The alarm will go off in 3 seconds!"
alertTime = Now + TimeValue("00:00:03")
Application.OnTime alertTime, "msg"
End Sub

Sub msg()
MsgBox "Three Seconds is up!"
End Sub


Rate This Tip
12 34 5
Rating: 3.38     Views: 59817
Execute Command/Sub-Procedure Using Timer in VBA
Begginner
On running the code above in Access
the .OnTime is highlighted and a message comes up saying:
Method or data member not found
Execute Command/Sub-Procedure Using Timer in VBA
rdwray@isp.com
Took you code and pasted into excel after trying my own and cannot get either one to work in 2002.
Click here to post comment
For Registered Users
Name
Comment Title
Comments