Creating a New Database

Finally, you can create a new database that is encrypted to begin with:

Sub CreateAndEncrypt(strDatabase As String, strPassword As


'Make sure the database does not exist

If Dir(strDatabase) <> "" Then

MsgBox "The specified database already exists: " &

strDatabase, vbExclamation

Exit Sub

End If

'Make sure the new password is between 1-20 characters

If Len(strPassword) < 1 Or Len(strPassword) > 20 Then

MsgBox "Password must be between 1 and 20 characters", vbExclamation

Exit Sub

End If

'Ok, now create the database and set the new password

DBEngine.CreateDatabase _

strDatabase, _

dbLangGeneral & ";PWD=" & strPassword

End Sub

0 0

Post a comment