Password Problem

A

Anatoly Kurilin

Hi, I normally use this code for modifying tables in backend files:
Set dbsBackEnd = DBEngine.OpenDatabase(strBackEndFileSpecs)
Set tdfIncome = dbsBackEnd!tblIncome
and so on.

This time I need to modify tables in a database with a password. I use this
code
Set dbsBackEnd = DBEngine.OpenDatabase(strBackEndFileSpecs,,, "PWD = " &
strDatabasePwd)
But each time I run it, I get an error message: "Not a valid password"

I supply a valid password. What do I do wrong?

Thanks in advance,
Anatoly
 
T

Tom Wickerath

Hi Anatoly,

Here is a procedure that I have used in the past with success:

'************************************

Sub OpenPasswordProtectedDB2(strPassword As String)
' A modified version of the original code in KB 235422, which allows one
' to specify the password at run-time.
' Note: Password is case sensitive.

'Define as Static so the instance of Access doesn't close when the
procedure ends.
Static acc As Access.Application
Dim db As DAO.Database
Dim strDbName As String

strDbName = "C:\Codescratch\Test.mdb"
strPassword = ";PWD=" & strPassword & ""

Set acc = New Access.Application
acc.Visible = True
Set db = acc.DBEngine.OpenDatabase(strDbName, False, False, strPassword)
acc.OpenCurrentDatabase strDbName
db.Close
Set db = Nothing
End Sub


'************************************

Tom

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________

:

Hi, I normally use this code for modifying tables in backend files:
Set dbsBackEnd = DBEngine.OpenDatabase(strBackEndFileSpecs)
Set tdfIncome = dbsBackEnd!tblIncome
and so on.

This time I need to modify tables in a database with a password. I use this
code
Set dbsBackEnd = DBEngine.OpenDatabase(strBackEndFileSpecs,,, "PWD = " &
strDatabasePwd)
But each time I run it, I get an error message: "Not a valid password"

I supply a valid password. What do I do wrong?

Thanks in advance,
Anatoly
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top