[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

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

Posted on 2014-03-10
5
Medium Priority
?
3,033 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 81

Accepted Solution

by:
zorvek (Kevin Jones) earned 500 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 500 total points
ID: 39918206
accapp.OpenDatabase("c:\database\mydatabase.mdb"), False, False, ";PWD=mypassword")
0
 
LVL 58

Assisted Solution

by:Gary
Gary earned 500 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 500 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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

650 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