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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run a Macro Once after timer

Status
Not open for further replies.

webjunk

MIS
Dec 28, 1999
42
0
0
US
What do I need to do if I want to run a macro 10 seconds after I open a form. I tried the Timer Interval but it keeps running the macro every 10 seconds.

(Repost)

Thanks in advanced
 
The trick is to let the timer event run once; then set the timer interval to 0; ie:

(a) Ensure that the timer interval property is set to 10000 milliseconds in the design view of the form

(b) At the end of the timer event code, set the timerinterval property to zero. This will prevent the interval from 'firing' again once it has run the first time.

For example:

Private Sub Form_Timer()
'-------------------
'Your code goes here
'-------------------
MsgBox "Put timer event code here"
' ...
' ...

'----------------------------
'prevent code from re-running
'----------------------------
Me.TimerInterval = 0
End Sub


Cheers,

Steve Lewy
Solutions Developer
steve@lewycomputing.com.au
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top