When to Use the DAO Layer

DAO provides a generic layer of functionality. It’s designed to insulate the programmer from the proprietary details of the back-end data source. For example, the following code excerpt will work with any data source, provided this data source has a table named Depts, which has a field named DeptName.

. . .
lstDepts.Clear
Set rsDepts = dbEmployees.OpenRecordset(“Depts”)
Do While Not rsDepts.EOF
    lstDepts.AddItem rsDepts.Fields(“DeptName”).Value
    rsDepts.MoveNext
Loop
rsDepts.Close
. . .

In the case of ODBC databases, the DAO layer provides the interface to the ODBC API. If the databases are local or client-based, such as Microsoft Access or FoxPro, the DAO layer provides a single interface, via Jet, to the diverse database formats.