473,890 Members | 1,405 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Discussion: DAO.DBEngine.Wo rkspaces() versus DAO.Workspaces( )

32,584 Recognized Expert Moderator MVP
My question, or point of discussion if you like, is why is the default Workspace object always described as DBEngine.Worksp aces(0) and not the simpler Workspaces(0) which, according to all I've discovered, is the same thing. Am I missing something important? I couldn't even find a reference that confirmed that the references are the same, although they are both from the DAO library.

I'm looking for a way to determine the actual Workspace object involved when dealing with a Database object. I'm surprised the DAO.Database object doesn't have a simple property pointing to the workspace it's within, but it doesn't. The best I have so far is :

Expand|Select|Wrap|Line Numbers
  1. 'WorkspaceFromDB() returns the Workspace object that contains dbSought.
  2. Public Function WorkspaceFromDB(ByVal dbSought As DAO.Database) As DAO.Workspace
  3.     Dim wsVar As DAO.Workspace
  4.     Dim dbVar As DAO.Database
  6.     For Each wsVar In Workspaces
  7.         For Each dbVar In wsVar.Databases
  8.             If dbVar Is dbSought Then
  9.                 Set WorkspaceFromDB = wsVar
  10.                 Exit Function
  11.             End If
  12.         Next dbVar
  13.     Next wsVar
  14. End Function
Nov 18 '12 #1
23 7553
8,834 Recognized Expert Expert
To the best of my knowledge, there is no easy way to determine the actual Workspace Object referenced by a specific Database. Your workaround looks like a good solution. Just out of curiosity, why do you need to determine the Workspace Object for a specified DB?
Nov 18 '12 #2
32,584 Recognized Expert Moderator MVP
Just out of curiosity, why do you need to determine the Workspace Object for a specified DB?
I'm writing routines that execute batches of SQL commands that should be run as a single transaction. Transactions, and the methods that go with them, are things that work at the Workspace level, so, while the SQL must be executed on the Database object, the Transaction is defined by the related Workspace object. As such, the Database and the related Workspace objects are both required.
Nov 19 '12 #3
5,501 Recognized Expert Moderator Expert
First paragraph under the list:
When you first refer to or use a Workspace object, you automatically create the default workspace, DBEngine.Worksp aces(0).
It maybe the matter of being "more correct" in the description of the workspace.

I for one, whenever using this method, have always used the full construct much like I do with the DAO.* objects to ensure that there is no misunderstandin g the code parser - I simply do not trust the developers not to muck things up with some new or changed library reference. :)
Nov 19 '12 #4
32,584 Recognized Expert Moderator MVP
That was my best guess Z. The linked page seems also to work on that basis in that it seems to use them interchangably, yet it doesn't ever explain that explicitly (which is pretty poor for an official page - apparently switching between them randomly with no explanation). If anyone knows where that is confirmed I'd be interested to see.
Nov 19 '12 #5
8,834 Recognized Expert Expert
I, like zmbd, have always fully qualified the Workspace Object with DBEngine to avoid any possible conflicts. Aside from brevity, I do not see any reason to not use the DBEngine.Worksp aces(?) Construct.
Nov 19 '12 #6
32,584 Recognized Expert Moderator MVP
I'm still looking for confirmation that they are equivalent. I've seen articles where the assumption seems apparent, but none that explain the situation or even refer explicitly to their being equivalent references to the same collection.

As far as I can see from my own checking, Workspaces() is a DAO collection just as DBEngine is a DAO object. My experimenting has shown them to be equivalent in the extremely limited test environment (with simply the * Default Workspace * existing) that I've used.
Nov 19 '12 #7
2,322 Recognized Expert Moderator Top Contributor
Do any of you ever use anything BUT the default workspace? And if so for what purpose, and why not use the default workspace?
Nov 21 '12 #8
8,834 Recognized Expert Expert
Personally, I never had any reason to use anything but the Default Workspace.
Nov 21 '12 #9
32,584 Recognized Expert Moderator MVP
Do any of you ever use anything BUT the default workspace? And if so for what purpose, and why not use the default workspace?
No. Not yet.

If I were to though, it would be to ensure that updates I applied were not counted as part of a transaction.

It should be bourn in mind however, that the Default Workspace and CurrentDb() are not used by the Access interface when dealing with the open database. Running action queries manually (or even via the DoCmd.RunSQL etc commands) will ensure that the changes are outside the scope of any defined transactions in the Default Workspace. This can be a bit of a gotcha if you have procedures, as I do, to do specific tasks that use this approach. I had to recode how my record deletions were invoked for this very reason.
Nov 22 '12 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

by: John Salerno | last post by:
After my last post, I thought of another question as a result of the following: ------------------------------ Mike Meyer wrote: > John Salerno <johnjsal@NOSPAMgmail.com> writes: > > >>So my question is, is this feasible? >
by: Joshua D. Drake | last post by:
Hello, I think the below just about says it all: http://www.commandprompt.com/images/mammoth_versus_dolphin_500.jpg Sincerely, Joshua Drake
by: RC | last post by:
In my Access 2002 form, I have a combo box and on the AfterUpdate event I use DoCmd.RunSQL ("UPDATE .... to update records in a table. When it starts to run I get a message "You are about to update 3 row(s)." Is there a way to prevent the message from popping up?
by: ctyrrell | last post by:
Does anyone have any idea how to recover from a run-time error 3002 which I get after creating a workspace 242 times? Or better yet, avoid getting it in the first place? I am creating a workspace with a blank password for different Users in order to find out which Users do not have passwords. This works just fine if I do it a few times, but if I want to do it periodically with a loop, it bombs out after 242 times of finding a user with...
by: travisperkins03 | last post by:
Hi, I have read somewhere that C code sometimes cannot be compiled to be as efficient as FORTRAN, eg for matrix multiplication, because a C compiler cannot make the assumptions about arrays that a FORTRAN compiler can. But I don't understand the example, not least because I don't understand FORTRAN. I also don't understand why it is more efficient in this case for a compiler to choose the order of evaluation (or whatever it is that it...
by: Daniel Bass | last post by:
I'm just getting into the .Net experience from a VC++ (6.0) background, and am looking at the .Net languages. Just wondering what the differences are, in your opinion, between C# and VB, dispite the obvious syntax changes between the two where '}' is 'End Sub', and the fact you can still have "modules" in VB, where as C# is toltally OO. The .Net libraries that are exposed to both seem to be identical, so what advangtages/disadvantages,...
by: david epsom dot com dot au | last post by:
I just wanted to test the behaviour of dao.dbEngine compared to dao.dbEngine.35 and dao.dbengine.36, but it's not there. It's always been there before, but it's been years since I looked. This failed: set dbe = createobject("dao.dbEngine") And there is no value in the registry.
by: Xah Lee | last post by:
Tabs versus Spaces in Source Code Xah Lee, 2006-05-13 In coding a computer program, there's often the choices of tabs or spaces for code indentation. There is a large amount of confusion about which is better. It has become what's known as “religious war” — a heated fight over trivia. In this essay, i like to explain what is the situation behind it, and which is proper.
by: =?Utf-8?B?TmFyYXNpbWhhbQ==?= | last post by:
I have a VB program that uses the DBEngine.CreateWorkspace command to authenticate users in SQL Server. We are trying to move that from VB to C# and I am trying to understand what the equivalent is in C# for the same. Can anyone throw some light on this.
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.