Search Tools Links Login

Create an Access database with VB6


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.

About this post

Posted: 2017-12-21
By: vb6boy
Viewed: 656 times

Categories

Windows

Visual Basic 6

Attachments

No attachments for this post

Requirements

Reference to an installed Microsoft DAO Object Library is required.


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.