Backend database password

P

Paul

I am trying to protect my backend database by adding a
password to it and then issuing the Opendatabase method
using the password to re-link the tables. I am getting an
error message Invalid password using the code below. This
seems to follow the format as outlined in the
documentation but I must be doing something wrong. ANy
help would be greatly appreciated!

Public Function Relinktables(strFilename As String)
Dim dbbackend As DAO.Database, dblocal As DAO.Database, ws
As Workspace, x, y
Dim tdlocal As DAO.TableDef
On Error GoTo Err_Relink
Set dbbackend = DBEngine(0).OpenDatabase
(strFilename, , , "; pwd=abc")
 
B

Brendan Reynolds

The following example works for me. I think you just need to take out the
semi-colon.

Public Sub OpenPasswordProtectedDatabase()

Dim db As DAO.Database

Set db = DBEngine.OpenDatabase(CurrentProject.Path & "\testdata.mdb", ,
, "pwd=password")
Debug.Print db.TableDefs(0).Name
db.Close
Set db = Nothing

End Sub


--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
W

Wayne Morgan

Brandon,

I just tried the following in Access 2003 and get Invalid Password. I've
unset and reset the password and tried with and without the semicolon. I
agree, it should work, but there does appear to be a problem here unless you
see a typo in what I have.

Public Sub testdb()
Dim db As DAO.Database
Set db = DBEngine.OpenDatabase("c:\temp\testdatabase.mdb", , , "pwd=test")
db.Close
Set db = Nothing
End Sub
 
P

Paul

Brendan,

I tried removing the semi-colon but still get the same
error message. Any other thoughts or is there a better
way to protect the backend database?

Thanks Paul
 
P

Paul

Wayne
I found the answer to the problem and it works.. see the
following KB article
http://support.microsoft.com/default.aspx?scid=kb;en-
us;209953&Product=acc2000
Paul
-----Original Message-----
Brandon,

I just tried the following in Access 2003 and get Invalid Password. I've
unset and reset the password and tried with and without the semicolon. I
agree, it should work, but there does appear to be a problem here unless you
see a typo in what I have.

Public Sub testdb()
Dim db As DAO.Database
Set db = DBEngine.OpenDatabase
("c:\temp\testdatabase.mdb", , , "pwd=test")
 
B

Brendan Reynolds

Hi Paul,

I see from your reply to Wayne that you found the solution. For the benefit
of anyone else who might be following the thread, it appears that under some
circumstances if you use the connect argument of the OpenDatabase method you
need to also provide values for the options and read-only arguments, even
though they are documented as being optional arguments.

I say 'under some circumstances' because the code worked for me without
specifying values for those arguments. I'm not sure whether this is a
difference between versions of Access, or between versions/service releases
of one of the other components involved (Jet, DAO, VBA).

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 

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