Public Function ChangeDatabasePassword(DBPath As String, _
newPassword As String, oldPassWord As String) As Boolean
`Usage: Change DatabasePassword
`Parameters: sDBPath: Full Path to Access Database
`newPassword: the password
`oldPassword: the previous password
`returns true on success false otherwise
If Dir(DBPath) = "" Then Exit Function
(本文来源于图老师网站,更多请访问http://m.tulaoshi.com/bianchengyuyan/)Dim db As DAO.Database
On Error Resume Next
Set db = OpenDatabase(DBPath, True, False, ";pwd=" & oldPassWord)
If Err.Number 0 Then Exit Function
db.newPassword oldPassWord, newPassword
ChangeDatabasePassword = Err.Number = 0
db.Close
End Function