|  

» 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.37     Views: 55700
Compile error "Method or data member not found"
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.
Re: Execute Command/Sub-Procedure Using Timer in VBA
LLA
Hi there,
I have got a problem with this simple procedure, cause it can't find the way of the second one (named : msg).
The procedure timeMsg is perfect, but when it's arrived at "Application.OnTime alertTime, "msg", it is the bug!!!
This one is just above in my thisWorkbook.
Is someone can help me?
Many thanks to you.
LLA
Re: Execute Command/Sub-Procedure Using Timer in VBA
shg
Welcome to the forum.

Please take a few minutes to read the forum rules, and then start your own thread in one of the question forums. This isn't one.

Thanks.
Click here to post comment
For Registered Users
Name
Comment Title
Comments