| DatabaseLessons.com |
'Serving the Microsoft® Access |
|
|
Referencing DAO in Microsoft® Access VBAI use DAO exclusively. I have NEVER used ADO. What is DAO? It is an acronym for Data Access Objects. The most important function of DAO is to provide you with a way to manipulate your data. The most common DAO object that you will see in my examples is the recordset object. Why DAO? It was designed specifically for the Jet Engine, which is what stand-alone MS Access databases use. It is more efficient for some processes in Access. Example.
Dim db as database
set db=currentdb If you start up Microsoft® Access 2000 and type the above code into a VBA module in a new database, it will not work. Why? Because, by default, Access 2000 does not turn DAO on. You have to do that. Just open up your VBA editor, go to the Tools menu, choose References, check off the ADO entry, find DAO 3.x, check it on, and exit the dialogue box. Now the code will work. If you need to use both ADO and DAO, explicitly declare DAO references.
Dim db as DAO.database
set db=currentdb How to Turn DAO onTo watch a 1 minute video that will show you how I turn DAO on whenever I create a new database in MS Access 2000, click on the photo below. ![]() |
|
|
© 2006, 2007, 2008 Richard W. Killey. All Rights Reserved. |