Create an Access database with VB6

Posted On 2017-12-21 by VB6Boy
Tags: VB6 Databases VB6 Miscellaneous Windows
Views: 145

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.


Reference to an installed Microsoft DAO Object Library is required.

About the Author

VB6Boy has posted a total of 71 articles.

Comments On This Post

No comments on this post yet!

Do you have a thought relating to this post? You can post your comment here. If you have an unrelated question, you can use the Q&A section to ask it.

Or you can drop a note to the administrators if you're not sure where you should post.

Your IP address is:

Before you can post, you need to prove you are human. If you log in, this test goes away.

Code Links