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,

Share the Post:
Share on facebook
Share on twitter
Share on linkedin


Recent Articles: