Databases Reference
In-Depth Information
price].Value
End Sub
14.8.15 Indexes
An Indexes collection contains all of the saved Index objects (i.e., indexes) for a TableDef
object. We will discuss how to create an index in Chapter 15.
14.9 The CurrentDb Function
We have seen that DAO refers to the current database as:
DBEngine.Workspaces(0).Databases(0)
or, through default collections, as:
DBEngine(0)(0)
However, within Microsoft Access, there is a preferred way to refer to this database,
since, unlike DBEngine(0)(0) , it is always current with respect to changes made using
the Access graphical interface. This preferred way is to use the Access function
CurrentDb . Unfortunately, there is some confusion as to precisely what this function
does.
Here is part of what the Access help system says about this function:
The CurrentDb function returns an object variable of type Database that
represents the database currently open in the Microsoft Access window.
The CurrentDb function provides a way to access the current database
from Visual Basic code without having to know the name of the database.
Once you have a variable that points to the current database, you can also
access and manipulate other objects and collections in the data access
object hierarchy.
You can use the CurrentDb function to create multiple object variables
that refer to the current database. In the following example, the variables
dbsA and dbsB both refer to the current database:
Dim dbsA As Database, dbsB As Database
Set dbsA = CurrentDb
Set dbsB = CurrentDb
This certainly makes it appear as though the object variables dbsA and dbsB point to a
single Database object, namely, the currently open database. In other words, executing
the instruction:
 
Search WWH ::




Custom Search