Hi
Access 2002/2007
I have a problem when closing Access. Some of my forms are based on ADBDB Rs's on which I use SQL transactions. I build a string (SQLLine) in the form-open and then add the ADODB Rs to the form. So.....
My Error Handling includes cancellation(s) of the changes. So .....
If successful, I commit and close the connection in an 'Apply' button click event.... so....
If user cancels then I rollback and close...
In any of the cases, the CNX should get closed.
However, if I do experience a problem (which is a lot when developing) and try to close Access (using 'x') it hangs up and I have to use Task Manager to kill it. I'm pretty sure this is cos' of an outstanding CNX?
Does anyone know how to cycle around any/all open connections and close them? I could run that in a 'close' macro. I look around but think I must be on Access' leading edge!
thanks
Access 2002/2007
I have a problem when closing Access. Some of my forms are based on ADBDB Rs's on which I use SQL transactions. I build a string (SQLLine) in the form-open and then add the ADODB Rs to the form. So.....
Code:
Set Edit_Cnn = CurrentProject.Connection
Edit_Cnn.BeginTrans
Edit_Transaction_Begun = True
'Create an instance of the ADO Recordset class and set its properties
Set Edit_rstADO = New ADODB.Recordset
With Edit_rstADO
Set .ActiveConnection = Edit_Cnn
.Source = SQLLine
.LockType = adLockOptimistic
.CursorType = adOpenStatic
.CursorLocation = adUseClient
.Open
End With
Set CntrlBx.Form.Recordset = Edit_rstADO
My Error Handling includes cancellation(s) of the changes. So .....
Code:
If Edit_Transaction_Begun Then
Edit_Cnn.RollbackTrans
Edit_Transaction_Begun = False
End If
'Close the ADO connection we opened
Edit_Cnn.Close
Set Edit_Cnn = Nothing
If successful, I commit and close the connection in an 'Apply' button click event.... so....
Code:
If Edit_Transaction_Begun Then
Edit_Cnn.CommitTrans
Edit_Transaction_Begun = False
End If
'Close the ADO connection we opened
Edit_Cnn.Close
Set Edit_Cnn = Nothing
If user cancels then I rollback and close...
Code:
If Edit_Transaction_Begun Then
Edit_Cnn.RollbackTrans
Edit_Transaction_Begun = False
End If
'Close the ADO connection we opened
Edit_Cnn.Close
Set Edit_Cnn = Nothing
In any of the cases, the CNX should get closed.
However, if I do experience a problem (which is a lot when developing) and try to close Access (using 'x') it hangs up and I have to use Task Manager to kill it. I'm pretty sure this is cos' of an outstanding CNX?
Does anyone know how to cycle around any/all open connections and close them? I could run that in a 'close' macro. I look around but think I must be on Access' leading edge!
thanks