1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| Function SetDBPassword(ByVal strDBPath As String, _
ByVal strOldPwd As String, _
ByVal strNewPwd As String)
' This procedure sets a new password or changes an existing
' password.
Dim dbsDB As DAO.Database
Dim strOpenPwd As String
' Create connection string by using current password.
strOpenPwd = ";pwd=" & strOldPwd
' Open database for exclusive access by using current password. To get
' exclusive access, you must set the Options argument to True.
dbsDB = OpenDatabase(Name:=strDBPath, _
Options:=True, _
ReadOnly:=False, _
Connect:=strOpenPwd)
' Set or change password.
With dbsDB
.NewPassword(strOldPwd, strNewPwd)
.Close()
End With
dbsDB = Nothing
Return True
End Function |
Partager