Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Urgent - What does Set db = DbEngine(0)(0) mean???

Status
Not open for further replies.

RenaissanceJo

Technical User
Sep 14, 2000
6
GB
I was having a problem turning off system messages when I was running a action query.

Some one from one of the access news groups told me to use:
Dim Db as DAO.Database
Set db = DbEngine(0)(0)

db.Execute ("NameOfYourQuery")

Are the first 2 lines safe because since using it, access 2k cant find ANY of my querys that I call from code??????

Thanks

Jo
[sig][/sig]
 
Here's a quick and loose answer: the (0) refers to the first item in a collection of possible db engines. I don't think I've ever seen a reference to more than one db engine instance at a time. Most collections have zero based indexes, that is, the items are numbered starting at zero. So a collection with an index of three, such as Forms(3) has four members. Look up "collections" in the Help or press Alt F11 to go into the Visual Basic editor and search the Visual Basic help for the same topic. [sig][/sig]
 
DBEngine(0)(0) is the same thing as DBEngine.Workspaces(0).Databases(0), which is also what Access calls CurrentDB. According to a reference book I have ("Access97 Developer's Handbook" by Litwin/Getz/Gilbert), the DBEngine(0)(0) sytax is required if you're trying to control DAO.

They make a note that while it isn't true in Access97, it's "possible that a future version of Access will support multiple databases open on the Access desktop." They say that in that case (0)(0) might not refer to the current database, but just the first one that was added to the databases collection.

I'm still working in 97, so I can't say if that's what's going on, but you might want to look in that direction.

[sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top