devxlogo

Creating an MSACCESS Database through VB

Creating an MSACCESS Database through VB

I have frequently seen bulletin board requests on how to create MSACCESS databases with VB. To do this, add a reference to the Microsoft DAO _._ Object Library (I am using Version 3.6 for the sample code below). Add the sample code where appropriate (e.g., call it from button click events on a form, and so on). The routine names are self-explanatory and the code is commented appropriately. Give it a whirl!

 Public Sub CreateDB(ByVal pDatabaseUNC As String)    Dim ws As Workspace    Dim db As Database    On Error GoTo Routine_Error    'Create a new Database with the specified name    Set ws = DBEngine.Workspaces(0)     'Default Workspace    Set db = ws.CreateDatabase(pDatabaseUNC, dbLangGeneral)    'Add a new table to the newly created database    CreateTable db,
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist