I need to execute several sql clauses, inserts, updates and delete for example. How to use a transaction in Access to bind them together?
DAO is preferred.
like:
BeginTrans
Excute SQL_1
Excute SQL_2
.....
CommitTrans
Thanks!
Here is a more complete skeleton...
Dim ws As DAO.Workspace
Dim in_trans As Boolean
Sub Transaction()
On Error GoTo Trans_Error
Set ws = DBEngine.Workspaces(0)
in_trans=True
ws.BeginTrans
<do some SQL stuff; maybe use Err.Raise>
ws.CommitTrans
in_trans=False
Trans_Exit:
Set ws = Nothing
Exit Sub
Trans_Error:
If in_trans = True Then
ws.Rollback
EndIf
Resume Trans_Exit
End Sub
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With