DAO Workspace in Access 2007

  • Thread starter Thread starter AG
  • Start date Start date
AG said:
According to KB article http://support.microsoft.com/kb/928025/en-us
A DAO Workspace can not be created in Access 2007.
How can a DAO operaton be wrapped in a transaction so that it can be
rolled back in case of failure, since transaction operations are Workspace
methods?


You can't *create* a workspace object, apparently, but you can use the
existing one that Access is using. For example:

Dim ws As DAO.Workspace

Set ws = DBEngine.Workspaces(0)

ws.BeginTrans

ws(0).Execute _
"INSERT INTO Table1 (TextField) VALUES('Transaction')", _
dbFailOnError

If MsgBox("Commit this update?", vbYesNo, "Commit?") _
= vbYes _
Then
ws.CommitTrans
Else
ws.Rollback
End if

Set ws = Nothing
 
Back
Top