none
How to chekc if there are active transactions? RRS feed

  • Question

  • Hi Folks -

    Is there an easy way to check if there is an active transaction going on? Upon scouring the interwebs, it doesn't seem like there is.

    Essentially, I have an err exit routine that I want to check when to rollback:

    Proc_Exit:
    
        Set objexcel = Nothing
        Set rsQuery = Nothing
        Set dbs = Nothing
        Set ws = Nothing
        Set RS = Nothing
        
        Exit Function
    
    Proc_Err:
    
        If Len(strStep) > 0 Then
            EmailStep = strStep & vbNewLine & vbNewLine
        Else
            EmailStep = ""
        End If
        
        strSubject = "WARNING : Function '" & strFunctName & "' Failed"
        strBody = strSubject & vbNewLine & vbNewLine & _
                  EmailStep & _
                  "Profile : " & CurrentUser() & vbNewLine & vbNewLine & _
                  "VB Module : " & Application.VBE.ActiveCodePane.CodeModule.name & vbNewLine & vbNewLine & _
                  "VB Error : " & Err.Description
        strTo = "email@client.com"
        Call MDM_Routines.Email_Utility(strSubject, strBody, strTo, "", "")
        
        ws.Rollback
        
        Dim sKillExcel As String
        sKillExcel = "TASKKILL /F /IM Excel.exe"
        Shell sKillExcel, vbHide
        
        Resume Proc_Exit
        
    End Function

    Would love to be able to just run If ws.BeginTrans is true....yadda yadda yadda .

    Thakns!

    Friday, April 3, 2020 7:09 PM

All replies

  • There isn't. You can use a local boolean variable and set it to True after BeginTrans, and back to False after Commit. Then you can test for it in your error handler.

    -Tom. Microsoft Access MVP

    Friday, April 3, 2020 7:58 PM