open password protected database.

kevinnichols78

Board Regular
Joined
Aug 30, 2004
Messages
112
Hi all,

I'm trying to open a database from another database. The one I'm trying to open is protected with a password. As I understand it, this code should work:

Sub Begin()

Dim wsp As Workspace
Dim dbs As Database, dbsAnother As Database
Dim tdf As TableDef

' Return reference to current database.
Set dbs = CurrentDb
' Return reference to default workspace.
Set wsp = DBEngine.Workspaces(0)
' Return reference to Another.mdb.
Set dbsAnother = wsp.OpenDatabase("C:\Data.mdb", , , "ODBC;PWD=password")



However, it doesnot. It finds the database and tries to open it, but gives me a password invalid message. Now I know that that password is correct because I can type it in and it will open the database. SO, any other ideas?

Kevin
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Is the password actually 'password'?
 
Upvote 0
no, but if it was, that is what i have entered.

Say the password is 'bob' I'd have 'bob' typed there instead of 'password' :)

Kevin
 
Upvote 0
The only real thing i can think of is to remove the password from the database. it would most likely work then. but other than that i got nothing for you.
 
Upvote 0
I'm NOT trying to crack the password. I know exactly what it is. I CREATED it. I'm just trying to open that password protected database from another database. I can use it without a password, however I would prefer the little bit of security that having a password there will offer. It will keep those that aren't trying to corrupt data from doing just that. :)

Kevin
 
Upvote 0
Are you using the database on a networked computer???
And if it is is it in a shared folder?
because unless it is, then i dont really see any reason for having a password on it, unless there are other people that use that computer.
You could possible just put it in a password locked folder or container so that people cant open it without a password but it might just work for you to do what u need to do.
But the only thing is im not sure if its possible for there to be a password locked folder... lol
there might be a way.
Or to stop other people from using it create a username and password for the computer so that you are the only one to be able to get into the folder therefor disallowing access from other users of that computer...
 
Upvote 0
Solution

Reference:
Microsoft DAO 3.6 Object Library

Code:
Sub OpenDB()
Dim db As DAO.Database
Dim ws As DAO.Workspace
Dim rst As DAO.Recordset
Dim strSQL As String
strSQL = "Select * from data where * <> null"
Set ws = DBEngine.Workspaces(0)
Set db = ws.OpenDatabase ("C:\data.mdb", False, False, "MS Access;PWD=password")
Set rst = db.OpenRecordset(strSQL, dbOpenDynaset)
If rst.RecordCount > 0 Then
Do Until rst.EOF
Debug.Print rst!record
rst.MoveNext
Loop
End If
rst.Close
db.Close
End Sub
 
Upvote 0

Forum statistics

Threads
1,221,848
Messages
6,162,415
Members
451,762
Latest member
Brainsanquine

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top