'First quote McrSoft Dao 3.6 (or 2.5 or 3.51) Object Library and McRSoft Access 9.0 Object Library, add a command1 on the Form, paste the following code:
Private Sub Command1_Click () DIM WRKDEFAULT AS WORKSPACE DIM DBSNEW AS DATABASE DIM TDFNEW AS TABEDEF DIM NewDB As Database
If Dir ("D: /NewDb.mdb") <> "" D: /NewDb.mdb "{Remove the current directory: if Dir (" newdb.mdb ") <>" "" "NewDB.mdb")} Set wrkDefault = DBEngine.Workspaces (0) Set dbsNew = wrkDefault.CreateDatabase ( "d: /NewDB.mdb", dbLangGeneral, dbEncrypt) '{get current directory, then remove the path: Set dbsNew = wrkDefault. CreatedTabase ("NewDb.mdb", dblangGeneral, dbncrypt)} dbsnew.newpassword "", "123" set database password 123 set wrkdefault = Nothing set dbsnew = nothing
End Sub