Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between DBEngine.BeginTrans and DBEngine.Workspaces(0).BeginTrans

In Access, what is the difference between these two statements?

DBEngine.BeginTrans

and

DBEngine.Workspaces(0).BeginTrans

The documentation for both leads to the same place.

like image 714
Shane Miskin Avatar asked Jan 07 '09 21:01

Shane Miskin


2 Answers

Have a look here: DAO Workspace
And then here: DAO Workspace: Opening a Separate Transaction Space

(The links are for MFC, but they're applicable to whatever you're coding in.)

DBEngine.Workspaces(0) is the default workspace. Other workspaces can be created, which let you work with separate sessions; the idea is that BeginTrans and EndTrans apply to the whole workspace, but if you need to do stuff outside that transaction, you can create another workspace and use it independently of your transactions in the first workspace.

Personally, I never had occasion to use more than one workspace when doing DAO in VBA. * shrug *

like image 192
Ryan Lundy Avatar answered Oct 28 '22 18:10

Ryan Lundy


My own answer:

It appears that DBEngine.BeginTrans and DBEngine.Workspaces(0).BeginTrans do the same thing because this code works (see below). "Workspaces" is the default member of DBEngine.

Dim db As Database
Set db = CurrentDb

DBEngine.BeginTrans
db.Execute "Update Table1 SET CITY='Newark'"
DBEngine.Workspaces(0).Rollback
like image 2
Shane Miskin Avatar answered Oct 28 '22 19:10

Shane Miskin