Creating a New Database Using DAO

Suppose that you want to automate the creation of a new Access database. With a new Excel workbook open, begin by establishing a VBA module. Choose Tools, Macro, Visual Basic Editor. With the VBE active, create a new module by choosing Insert, Module.

To create a database using DAO, you need to establish a reference to the DAO object library. Choose Tools, References and scroll down until you see a Microsoft DAO Object Library. The highest-numbered version is the one to use, and the versions available on your system depend on which version of Office you have installed. For Office 2003, that's Microsoft DAO 3.6 Object Library; for Office 1997, it's DAO 3.5. Fill its check box and click OK.

Providing the Code to ...

Get Managing Data with Microsoft® Excel now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.