When working with Access data, a DAO Database object represents (no surprise!) an Access database. (For working with other types of data, use the ADO object model.) To reference the current database, you can use the CurrentDb method of the Access Application object, after declaring the appropriate DAO Database variable, as in the following code:

Dim dbs as DAO.Database

Set dbs = CurrentDb

If you need to reference an external database, use the OpenDatabase method, with the name of an open database as its argument, as in the following code:

Dim dbs As DAO.Database Dim strDBName As String strDBName = "E:\Documents\Northwind.mdb" Set dbs = OpenDatabase(Name:=strDBName)

Once the database is open, you can proceed to work with it, using the Recordsets, QueryDefs, and TableDefs collections.

0 0

Post a comment