Pause Between Macros

  • Thread starter Thread starter Scott
  • Start date Start date
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.
 
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.
 
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>




.
 
Back
Top