Solved

how can i open with vba on microsoft access a database that is protected with a password

Posted on 2014-03-10
5
2,654 Views
Last Modified: 2014-03-10
hi


i have this code to open a non-protected database
Dim accapp As Access.Application
 
Set accapp = New Access.Application
 
accapp.OpenCurrentDatabase d("c:\database\mydatabase.mdb")
accapp.Visible = True

Open in new window


what i have to add to this code to open a database that protected with a password?

thanks
0
Comment
Question by:bill201
5 Comments
 
LVL 81

Accepted Solution

by:
zorvek (Kevin Jones) earned 125 total points
ID: 39918203
Some sample code illustrating how to do this:

   Set MyDatabase = New ADODB.Connection
   MyDatabase.CursorLocation = adUseClient
   MyDatabase.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source='C:\full\path\to\database.mdb'; User Id=admin; Password=;"

For more information about Open syntax:

    http://msdn.microsoft.com/en-us/library/ms808201.aspx

Additional help constructing connection strings can be found at:

    http://www.connectionstrings.com/

Kevin
0
 
LVL 6

Assisted Solution

by:c1nmo
c1nmo earned 125 total points
ID: 39918206
accapp.OpenDatabase("c:\database\mydatabase.mdb"), False, False, ";PWD=mypassword")
0
 
LVL 58

Assisted Solution

by:Gary
Gary earned 125 total points
ID: 39918224
Another option, authenticating yourself first then carrying on with your code as normal.

http://support.microsoft.com/kb/235422
0
 
LVL 61

Assisted Solution

by:mbizup
mbizup earned 125 total points
ID: 39918226
With the OpenCurrentDatabase command:

Dim accapp As Access.Application
dim strPwd as string

strPwd = "MyPassword123"
Set accapp = New Access.Application
 
accapp.OpenCurrentDatabase ("c:\database\mydatabase.mdb",, strPwd)
accapp.Visible = True

Open in new window

0
 

Author Closing Comment

by:bill201
ID: 39918290
thanks a lot for  your help.
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question