Pause Between Macros

S

Scott

Is there a way to pause 2 seconds or so before a second
macro goes off in the code builder? So far, my code is:

Private Sub Command35_Click()

DoCmd.RunMacro "Macro 1"
DoCmd.RunMacro "Macro 2"

End Sub

Thanks for the help.
 
K

Ken Snell

Easiest way I know would be to create a form (which you will open in dialog
mode) and use that form's Timer event to do the pause.

Create a form (name it "frmPause"). Set its TimerInterval property to 2000.
Put this code on the Timer event:

Private Sub Form_Timer()
DoCmd.Close acForm, Me.Name
End Sub

Change the code that you posted to this:

DoCmd.RunMacro "Macro 1"
DoCmd.OpenForm "frmPause", , , , , acDialog
DoCmd.RunMacro "Macro 2"

That should do it.
 
S

Scott

Works Great. Thanks for the help Ken.
-----Original Message-----
Easiest way I know would be to create a form (which you will open in dialog
mode) and use that form's Timer event to do the pause.

Create a form (name it "frmPause"). Set its TimerInterval property to 2000.
Put this code on the Timer event:

Private Sub Form_Timer()
DoCmd.Close acForm, Me.Name
End Sub

Change the code that you posted to this:

DoCmd.RunMacro "Macro 1"
DoCmd.OpenForm "frmPause", , , , , acDialog
DoCmd.RunMacro "Macro 2"

That should do it.
--
Ken Snell
<MS ACCESS MVP>




.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top