Connection.StillExecuting プロパティ (DAO)

適用先: Access 2013、Office 2013

構文

式 。StillExecuting

式Connection オブジェクトを表す変数です。

注釈

StillExecuting プロパティを使用して、直前に呼び出した非同期の Execute メソッドまたは OpenConnection メソッド (つまり、 dbRunAsync オプションを指定して実行したメソッド) が完了しているかどうかを調べます。 StillExecuting プロパティが True の間は、返されたオブジェクトにアクセスできません。

StillExecuting プロパティで False が取得された後で、関連付けられた Connection オブジェクトを返す OpenConnection メソッドを呼び出すと、そのオブジェクトを参照できます。 StillExecuting で True が取得される間は、 StillExecuting プロパティの取得を除き、そのオブジェクトに対する参照は実行できません。

処理中のタスクの実行を中止するには、 Cancel メソッドを使用します。

例

次の例では、 StillExecuting プロパティと Cancel メソッドを使用して、 Connection オブジェクトを非同期で開きます。

    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