Excel VBA To open a MS Access Password protected database

R

RMC

I've been trying to open a password protected MS Access database from
Excel VBA.

I've been using the following code to open nonm password protected
database with out an issue. Is there an additional perameter that I
need to add?


Here is the partial code:


Set G_Workspace = DBEngine.CreateWorkspace("", "admin", "")
Set G_Database = OpenDatabase(Name:=G_DatabaseName, ReadOnly:=True)


This returns error 3031 Invalid password,


Any info would be appreciated,


RMc
 
G

George Nicholson

If you need to supply a password, then the Connect becomes mandatory. If you
are opening a Jet/Access mdb, then it will *might* look *something* like the
following. However, your mileage may vary. Check out the DAO help file.

strConnect = "MS Access;PWD=" & strPWD
Set G_Database = OpenDatabase(Name:=G_DatabaseName, ReadOnly:=True,
Connect:=strConnect)

HTH,
 
R

RMC

If you need to supply a password, then the Connect becomes mandatory. If you
are opening a Jet/Access mdb, then it will *might* look *something* like the
following. However, your mileage may vary. Check out the DAO help file.

strConnect = "MS Access;PWD=" & strPWD
Set G_Database = OpenDatabase(Name:=G_DatabaseName, ReadOnly:=True,
Connect:=strConnect)

HTH,












- Show quoted text -

Thank's for the info, and a path forward, will test this out.

RMc
 
C

Chay Harley

Also, further to this, if your Access Database has permission assigned as a
group, then you'll need to create the groups inside access or the access
"groups" manager before you can get access to the file.

I encountered this with some commercial software. It was necessary to
recreate the security groups before you could access the underlying data.

HTH,
Chay Harley.
 

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