We help IT Professionals succeed at work.

VBA code to create empty .mdb file

thimerion
thimerion asked
on
Hi all,

Someone has the VBA code to create a new empty .mdb file?

Regards, Tim

Comment
Watch Question

   Dim wsp As Workspace
    Dim db As Database
    Set wsp = CreateWorkspace("JetWorkspace", "admin", "", dbUseJet)
    Set db = wsp.CreateDatabase("C:\YourNewDB.mdb", dbLangGeneral)
    Set db = Nothing
    wsp.Close
    Set wsp = Nothing
you can also add a password to the database by using:

    Set db = wsp.CreateDatabase("C:\YourNewDB.mdb", dbLangGeneral & ";pwd=YourPassword")


and the dbLangGeneral is optional (the default language will be used if this is omitted) so you really could just use:

    Set db = wsp.CreateDatabase("C:\YourNewDB.mdb", ";pwd=YourPassword")