Go Back   Access World Forums > Microsoft Access Discussion > General

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 08-18-2009, 08:11 PM   #1
genesis
Registered User
 
Join Date: Jun 2009
Posts: 205
Thanks: 0
Thanked 0 Times in 0 Posts
genesis has a little shameless behaviour in the past
How to open a password protected database

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.

genesis is offline   Reply With Quote
Old 08-18-2009, 11:06 PM   #2
DCrake
Remembered
 
DCrake's Avatar
 
Join Date: Jun 2005
Location: Burnley, Lancashire
Posts: 8,634
Thanks: 8
Thanked 325 Times in 208 Posts
DCrake is a glorious beacon of light DCrake is a glorious beacon of light DCrake is a glorious beacon of light DCrake is a glorious beacon of light DCrake is a glorious beacon of light DCrake is a glorious beacon of light
Send a message via Skype™ to DCrake
Re: How to open a password protected database

Do you know the password for the protected mdb?
__________________
David Crake


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
The Home of Simple Software Solutions.

O/S Windows XP (SP3) & Windows 7 64bit
Access 2003 (version 11.0)
Access 2007 (version 12.0)

Remember when posting sample databases you will get a better response if it is pre Access 2007 - not all people have it installed.
DCrake is offline   Reply With Quote
Old 08-19-2009, 12:13 AM   #3
genesis
Registered User
 
Join Date: Jun 2009
Posts: 205
Thanks: 0
Thanked 0 Times in 0 Posts
genesis has a little shameless behaviour in the past
Re: How to open a password protected database

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 by genesis; 08-19-2009 at 12:25 AM.
genesis is offline   Reply With Quote
Old 08-19-2009, 12:34 AM   #4
Atomic Shrimp
Humanoid lifeform
 
Join Date: Jun 2000
Location: Portsmouth, England
Posts: 1,954
Thanks: 0
Thanked 8 Times in 7 Posts
Atomic Shrimp has a spectacular aura about Atomic Shrimp has a spectacular aura about
Re: How to open a password protected database

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.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
- it's not radioactive, and contains only a few crustaceans.
Atomic Shrimp is offline   Reply With Quote
Old 08-19-2009, 12:42 AM   #5
genesis
Registered User
 
Join Date: Jun 2009
Posts: 205
Thanks: 0
Thanked 0 Times in 0 Posts
genesis has a little shameless behaviour in the past
Re: How to open a password protected database

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?
genesis is offline   Reply With Quote
Old 08-19-2009, 01:50 AM   #6
Atomic Shrimp
Humanoid lifeform
 
Join Date: Jun 2000
Location: Portsmouth, England
Posts: 1,954
Thanks: 0
Thanked 8 Times in 7 Posts
Atomic Shrimp has a spectacular aura about Atomic Shrimp has a spectacular aura about
Re: How to open a password protected database

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?)
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
- it's not radioactive, and contains only a few crustaceans.
Atomic Shrimp is offline   Reply With Quote
Old 08-19-2009, 02:26 AM   #7
DCrake
Remembered
 
DCrake's Avatar
 
Join Date: Jun 2005
Location: Burnley, Lancashire
Posts: 8,634
Thanks: 8
Thanked 325 Times in 208 Posts
DCrake is a glorious beacon of light DCrake is a glorious beacon of light DCrake is a glorious beacon of light DCrake is a glorious beacon of light DCrake is a glorious beacon of light DCrake is a glorious beacon of light
Send a message via Skype™ to DCrake
Re: How to open a password protected database

Code:
Public obDAO As DAO.Workspace, obDB As DAO.Database

Sub OpenConnection()

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


__________________
David Crake


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
The Home of Simple Software Solutions.

O/S Windows XP (SP3) & Windows 7 64bit
Access 2003 (version 11.0)
Access 2007 (version 12.0)

Remember when posting sample databases you will get a better response if it is pre Access 2007 - not all people have it installed.
DCrake is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Access 2007 spilt on server Joe8915 General 10 07-21-2010 04:42 AM
TransferDatabase - Creating a DB to Transfer info from 1 DB into another CNx Modules & VBA 1 10-24-2008 09:21 PM
How do you specify to open another database in the SAME folder chillwa Modules & VBA 1 06-18-2008 10:48 AM
Open database with password agust Modules & VBA 0 10-05-2006 08:06 PM
open another database within a database toddbingham General 2 10-27-2004 05:13 PM




All times are GMT -8. The time now is 08:12 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World