开发者

unable to remove password from Microsoft Access 2007 (accdb)

开发者 https://www.devze.com 2022-12-19 01:49 出处:网络
I have a Microsoft Access 2007 (accdb) file.I set a password on it.When I open it up now, I am prompted for a password.I enter the correct password and I can gain access to it.

I have a Microsoft Access 2007 (accdb) file. I set a password on it. When I open it up now, I am prompted for a password. I enter the correct password and I can gain access to it.

However, I want to remove the password. I click "Database tools", but in the database tools, I only see "Encrypt with password", contrary to the help file (which says I should see "decrypt password.")

It appears that the Access UI thinks I have no password, so it won't give me the option to remove the开发者_StackOverflow社区 password.

How can I get the password removed?


Create a new Access database Create a new Form Create Command button

execute below code (change code to reach your database and password)

Public Sub Command0_Click()
Dim objConn As ADODB.Connection
Dim strAlterPassword As String

On Error GoTo ChangeDBPassword_Err

' Create the SQL string to change the database password.
' Here, "It" is the old password, and I am wanting to set the password to NULL
'    Replace "It" with your password
strAlterPassword = "ALTER DATABASE PASSWORD NULL [It];"

' Open the secured database.
Set objConn = New ADODB.Connection

With objConn
.Mode = adModeShareExclusive
.Provider = "Microsoft.ACE.OLEDB.12.0"
'  Replace "It" with your old password
.Properties("Jet OLEDB:Database Password") = "It"
'The following specifies the location of the database of which PW I'm trying to change.
'    Replace path to your database 
.Open "Data Source= G:\Database\database.accdb;"
' Execute the SQL statement to change the password.
.Execute (strAlterPassword)
End With

' Clean up objects.
objConn.Close
Set objConn = Nothing

ChangeDBPassword_Err:
MsgBox Err.Number & ":" & Err.Description
End Sub

THANKS TO ERIC MATTHEW VAJENTIC


Did you open the database in "exclusive mode"?

File | Open | select database file | Triangle Next to the "Open" command button | Open Exclusive

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号