"paii, Ron" <pa**@packairinc.com> wrote in
news:k9********************@athenet.net:
Are the following 2 bits of code equivalent. I want to use ws for
transactions.
Dim ws as Workspace
Dim db as Database
Dim rs as Recordset
Set ws = DBEngine.Workspaces(0)
Set db = ws.Databases(0)
--------------------------------
Dim ws as Workspace
Dim db as Database
Dim rs as Recordset
Set ws = DBEngine.Workspaces(0)
Set db = CurrentDb
Just about everything you want to know was last discussed in this
thread:
http://groups-beta.google.com/group/comp.databases.ms-
access/msg/d530
add6df407824
That's my first post in the thread, which you can use to bring up
the treeview of the entire thread.
In short:
1. if your operations are on the currently opened database (the
front end), use CurrentDB().
2. if your operations are on a different db, use DBEngine and open a
different database/workspace, as necessary.
Actually, looking back on your coded examples, they are *not*
equivalent. In the second case, setting the workspace serves
absolutely no function.
And, of course, you can get the database pointer from
DBEngine.Workspaces(0).Databases(0), which can be abbreviated as
DBEngine(0)(0) because those are the default collections.
If you are doing transactions and need to use a workspace, you'll
use DBEngine.Workspace(0) or open a new one. CurrentDB() and
DBEngine(0)(0) have nothing to do with it.
--
David W. Fenton
http://www.bway.net/~dfenton
dfenton at bway dot net
http://www.bway.net/~dfassoc