Question How to open a password protected database (1 Viewer)

genesis

Registered User.
Local time
Today, 10:58
Joined
Jun 11, 2009
Messages
205
I have two database A and B.

database A is password protected.

How or what is the VBA code that I can make in a command button that in Database B that will open the database A (not link the table) application? I not that good at vba.

thanks.
 

DCrake

Remembered
Local time
Today, 18:58
Joined
Jun 8, 2005
Messages
8,634
Do you know the password for the protected mdb?
 

genesis

Registered User.
Local time
Today, 10:58
Joined
Jun 11, 2009
Messages
205
yes I do know the password because it is my work Dcrake.

can you teach me how to do that or what that vba code is.....

I have found this but i dont know if this is...............



Option Compare Database
Option Explicit

Sub OpenPasswordProtectedDB()

'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:\Program Files\Microsoft Office\Office\Samples\Northwind.mdb"
Set acc = New Access.Application
acc.Visible = True
Set db = acc.DBEngine.OpenDatabase(strDbName, False, False, ";PWD=nwind")
acc.OpenCurrentDatabase strDbName
db.Close
Set db = Nothing
End Sub



OR ----------------------------



Public Function OpenPasswordProtectedDatabase(DBPath As String, _
Password As String) As Object

'Usage: Open Password protected database
'Parameters: DBPath: Full Path to Access Database
'Password: the Password
'returns the database, in it's open state if successful.
'Otherwise return value will evalute to nothing

On Error Resume Next
Dim db As DAO.Database

Set db = DAO.OpenDatabase(DBPath, False, False, _
";pwd=" & Password)

If Err.Number = 0 Then
Set OpenPasswordProtectedDatabase = db
Else
Set OpenPasswordProtectedDatabase = Nothing
End If

End Function


that was just sample of what i have researched in the net.
 
Last edited:

Atomic Shrimp

Humanoid lifeform
Local time
Today, 18:58
Joined
Jun 16, 2000
Messages
1,954
What do you mean when you say 'open the database'?

I can't tell whether you mean that you want to connect to it to pull data out, or if you mean you want to launch a separate Access window with the database opened into it.
 

genesis

Registered User.
Local time
Today, 10:58
Joined
Jun 11, 2009
Messages
205
just open it to launch a separate access window with the database opened into it.

NOT link or import.

was my code above sufficient or not yet?
 

Atomic Shrimp

Humanoid lifeform
Local time
Today, 18:58
Joined
Jun 16, 2000
Messages
1,954
I don't think any of that code is going to launch a separate Access window (and I don't know how to do what you're asking.

(I'm also unsure why you'd want to do it - you're talking about opening up the back end - is this to provide an administrator-only backdoor or something?)
 

DCrake

Remembered
Local time
Today, 18:58
Joined
Jun 8, 2005
Messages
8,634
Code:
Public obDAO As DAO.Workspace, obDB As DAO.Database

Sub OpenConnection()

    Set obDAO = DAO.DBEngine.Workspaces(0)
    Set obDB = obDAO.OpenDatabase([B]strDBPath[/B], False, False, ";pwd=" & [B]DBPass [/B]& "")
    ConnectionState = True
    
End Sub
Where strDBPath is the full path and file name that you want to open and DBPass is the active password
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom