Connection.StillExecuting property (DAO)
Applies to: Access 2013, Office 2013
Syntax
expression .StillExecuting
expression A variable that represents a Connection object.
Remarks
Use the StillExecuting property to determine if the most recently called asynchronous Execute or OpenConnection method (that is, a method executed with the dbRunAsync option) is complete. While the StillExecuting property is True, any returned object cannot be accessed.
Once the StillExecuting property returns False, following the OpenConnection call that returns the associated Connection object, the object can be referenced. So long as StillExecuting remains True, the object may not be referenced, other than to read the StillExecuting property.
Use the Cancel method to terminate execution of a task in progress.
Example
This example uses the StillExecuting property and the Cancel method to asynchronously open a Connection object.
Sub CancelConnectionX()
Dim wrkMain As Workspace
Dim conMain As Connection
Dim sngTime As Single
Set wrkMain = CreateWorkspace("ODBCWorkspace", _
"admin", "", dbUseODBC)
' Open the connection asynchronously.
' Note: The DSN referenced below must be configured to
' use Microsoft Windows NT Authentication Mode to
' authorize user access to the Microsoft SQL Server.
Set conMain = wrkMain.OpenConnection("Publishers", _
dbDriverNoPrompt + dbRunAsync, False, _
"ODBC;DATABASE=pubs;DSN=Publishers")
sngTime = Timer
' Wait five seconds.
Do While Timer - sngTime < 5
Loop
' If the connection has not been made, ask the user
' if she wants to keep waiting. If she does not, cancel
' the connection and exit the procedure.
Do While conMain.StillExecuting
If MsgBox("No connection yet--keep waiting?", _
vbYesNo) = vbNo Then
conMain.Cancel
MsgBox "Connection cancelled!"
wrkMain.Close
Exit Sub
End If
Loop
With conMain
' Use the Connection object conMain.
.Close
End With
wrkMain.Close
End Sub