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]
 
Hi,
You a setting a referrence to the first database in the first workspace of the database engine's work spaces collection. "Set db = CurrentDB" will do the same thing. In the first line you are declaring a variable of type DAO.Database. The next line you are setting that variable to referrence the current database. Perfectly safe! However, if you don't understand this code, try simply doing this:

DoCmd.RunSQL "X"

where X is the name of a query or an embedded SQL statement.

Rob Marriott
CCTC1
rob@career-connections.net [sig][/sig]
 
you could also lose the dbengine(0)(0) code completly and use :-

original....

dim db as database
set db = dbengine(0)(0)
db.execute("Name of Your Query")


shorter....


currentdb().execute("Name of Your Query")


currentdb() is a function which effectively does the dbengine(0)(0) part for you, which is to return a pointer to the current database.

The (0)(0) would change to other numbers only if you were trying to access linked databases. [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top