Databases Reference
In-Depth Information
Data Access Objects (DAO)
DB Engine
Work sp aces
FIGURE 7.19 Data Access Objects — DAO hierarchy.
Once the project references the DAO, a small library of subroutines and functions can be built
to allow Excel VBA to write information to Access utilizing DAO. The first function created allows
the user to create a completely new database in Access from Excel. If the function is able to create
the database, it returns True; if it fails, it returns False. The user must specify a name for the new
database (FileName), and the path to which the database should be written to. Boolean passed
parameters allow the user to determine if existing databases should be overwritten, or if paths
should be created if they do not exist.
Function CreateMDBFile(FileName As String, FilePath As String, _
Optional DeleteExisting As Boolean, Optional CreatePath As
Boolean) As Boolean
'Creates Access Database at Location FilePath named FileName
'Returns True if successful
Dim ws As Workspace
FIGURE 7.20 Installing a reference to the DAO.
Search WWH ::




Custom Search