Back To Top

MS Access VBA Stop and Wait For versions 2000, 2002, 2003, 2007

Go here To Check if Field exists in VBA.
Follow the MS Access VBA Index Field Link to set a Fields Index and/or Set a field to Primary Key.


The VBA Stop and Wait Sample is available for download here in a zipped MS Access Database. The below picture (click to enlarge) shows the form.

MS Access VBA Form Stop and Wait 

The Actual VBA Code to Stop and Wait within a form, you should be able to copy/paste right into a module and use VBA to pause your application at will:

'Place the Declaration API at the top of your Module above
'All Subs and Functions

Declare Sub Sleep
Lib "kernel32" ( ByVal dwMilliseconds As Long )

Public Sub
Stop_Wait(numTime As Long )

'References: Microsoft Access 11.0 Object Library
   ' Set references by Clicking Tools and Then References in the Code View window
   ' Uses VBA to Stop or pause the current application for numTime seconds
   ' Accepts
   ' numTime: Time to wait in seconds
   'USAGE: Stop_Wait numTime

On Error GoTo errhandler

'Convert Time to wait to an interval equal to seconds
numTime = numTime * 1000

'Stops the execution of the code and waits
Sleep (numTime)


Exit Sub

'There is an error
With Err
MsgBox "Error " & .Number & vbCrLf & .Description, _
Or vbCritical, "Stop_Wait"
End With


End Sub

For the above VBA Stop and Wait Sub in an usable Form with Stop Button, download the Sample database in ZIP format. The sample includes one form and module.

For further help or suggestions go here: MS Access tutorials, Tables, Queries and later: Forms

You may post this tutorial on your website or in a forum. If you do please maintain a Link to Eraseve AP.

For further MS Access tutorials go here: MS Access tutorials

Go here To Check if Field exists in VBA.
Follow the Set Autonumber Field with VBA Link to Set a Field to Autonumber.


Did you find what you were looking for?
What would you suggest?
Your Name:
Your Message:
Your Email:



Custom Search