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>




.
 

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

Similar Threads

Change VBA code from a form 0
DoCmd.RunMacro code help? 2
Macro Error 1
Run Macro If Cell have "x" value 0
Macro question?? 4
Sendobject macro 1
Any ideas why Macro will not run... 3
Running a Macro in VB 1

Back
Top