先引用Mcrsoft DAO 3.6(或2.5或3.51) Object Library和Mcrsoft Access 9.0 Object Library,在Form上加个Command1,粘贴以下代码:Private Sub Command1_Click()
Dim wrkDefault As Workspace
Dim dbsNew As Database
Dim tdfNew As TableDef
Dim NewDB As Database
If Dir("D:\NewDB.mdb") <> "" Then Kill "D:\NewDB.mdb"
'{取当前目录的话去掉路径: If Dir("NewDB.mdb") <> "" Then Kill "NewDB.mdb")}
Set wrkDefault = DBEngine.Workspaces(0)
Set dbsNew = wrkDefault.CreateDatabase("d:\NewDB.mdb", dbLangGeneral, dbEncrypt)
'{取当前目录的话去掉路径: Set dbsNew = wrkDefault.CreateDatabase("NewDB.mdb", dbLangGeneral, dbEncrypt)}
dbsNew.NewPassword "", "123" '设置数据库密码为123
Set wrkDefault = Nothing
Set dbsNew = Nothing
End Sub