Create an Access database with VB6

By | 2017-12-21

Creating an Access database with VB6 should not be intimidating, and it is much simpler than you might think.  Four lines of code will do the job.

In your project, simply create a refrence to the latest Microsoft DAO Object Library. On my installation, this is shown as Microsoft DAO 3.6 Object Libary.

Once the necessary reference is made, simply use the following four lines of code to create an Access database:

Dim ws As Workspace
Dim db As Database
Set ws = DBEngine.Workspaces(0)
Set db = ws.CreateDatabase("C:\PathToDatabase\test.mdb", dbLangGeneral)

Make sure the path exists before you run the code, otherwise you’ll get an error.

Author: dwirch

Derek Wirch is a seasoned IT professional with an impressive career dating back to 1986. He brings a wealth of knowledge and hands-on experience that is invaluable to those embarking on their journey in the tech industry.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.