cravincreeks
Technical User
Hello all.
I'm hoping to modify my code to allow it to rollback many insert/update/delete SQL statements. If an error occurs in any part of my code, I'd like to roll back ALL transactions. Would the following code allow me to do so? Or does this only roll back one SQL statement at a time?
Public Sub CheckinTable()
'Begin transaction
Dim wkDefault As Workspace
Set wkDefault = DBEngine.Workspaces(0)
wkDefault.BeginTrans
On Error Go To errhandler
'the many insert/update/delete statements would go here, many of which are done in sub procedures
errhandler:
wkDefault.Rollback
End sub
Modifying my code to allow this would require me to make some substantial mods to my code and some existing tables. Before I invest the time, I'd like to know that this solution will work.
Thanks
AZ
I'm hoping to modify my code to allow it to rollback many insert/update/delete SQL statements. If an error occurs in any part of my code, I'd like to roll back ALL transactions. Would the following code allow me to do so? Or does this only roll back one SQL statement at a time?
Public Sub CheckinTable()
'Begin transaction
Dim wkDefault As Workspace
Set wkDefault = DBEngine.Workspaces(0)
wkDefault.BeginTrans
On Error Go To errhandler
'the many insert/update/delete statements would go here, many of which are done in sub procedures
errhandler:
wkDefault.Rollback
End sub
Modifying my code to allow this would require me to make some substantial mods to my code and some existing tables. Before I invest the time, I'd like to know that this solution will work.
Thanks
AZ