Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Advanced
Jan 8, 2001

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, 
Nazmul Siddiqui
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap