Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel VBA - Open Password protected Database

Status
Not open for further replies.

RonMck

IS-IT--Management
Dec 14, 2001
8
0
0
CA
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)

(code to query Database)

(Code to close database & Recordset)

This returns error 3031 Invalid password,


Any info would be appreciated,


 
What about something like this ?
Set G_Database = OpenDatabase(Name:=G_DatabaseName, ReadOnly:=True, Connect:=";PWD=yourPassword")

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Finally foud it with the assistance and direction from the forums.

Code used was:

Set G_Workspace = DBEngine.Workspaces(0)
Set G_Database = G_Workspace.OpenDatabase(G_DatabaseName, False, False, "MS Access;PWD=" & G_password)
You need the readonly and options declared as per MS Arcticle 209953
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top