Solved

Using a password protected access database

Posted on 2006-06-26
5
210 Views
Last Modified: 2010-04-07
Hi Experts.

Im using the following to connect to an access database: -

    Set dbMyDB = OpenDatabase(App.Path & "\db4.mdb")
    Set dbMyDB = OpenDatabase(App.Path & "\db4.mdb")

    Set rsMyRS = dbMyDB.OpenRecordset("Users", dbOpenDynaset)

I know its a crude way of connecting to the database but its easy. I'm trying to find out using the method above, how to connect to a password protected access database.

Many Thanks
Lee
0
Comment
Question by:ljhodgett
5 Comments
 
LVL 16

Expert Comment

by:Wadski
ID: 16982613
Hi there ljhodgett,

Using the OpenDatabase command to open a passworded database is covered on this MS support article:
http://support.microsoft.com/?kbid=209953



Wadski
0
 
LVL 15

Accepted Solution

by:
JackOfPH earned 125 total points
ID: 16982625
change it to this...

 Set dbMyDB = OpenDatabase(App.Path & "\db4.mdb", False, False, "MS Access;pwd=mypassword")
 Set dbMyDB = OpenDatabase(App.Path & "\db4.mdb", False, False, "MS Access;pwd=mypassword")

0
 
LVL 16

Expert Comment

by:Wadski
ID: 16982648
Although you should only need one Set dbMyDB line!
0
 
LVL 8

Expert Comment

by:hiteshgupta1
ID: 16983082
Hi,

If you are setting the password through Tools->Security->Database Password, then try this:

With myConnectionObject
     .Provider = "Microsoft.Jet.OLEDB.4.0"
     .Properties(15).Value = "mydatabasepassword"
     .open "C:\mydatabase.mdb"
end with

Property #15 is Jet OLEDB:Database Password and allows you to call the database password!

you can include it in the connection string as follows:
With cnnConnection
        .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=D:\mydatabase.mdb; Jet OLEDB:Database Password=mydatabasepassword"
        .Open
    End With

Let us know if it helps u!!
0
 
LVL 12

Expert Comment

by:jkaios
ID: 16990267
If you're using DAO:
  Set dbMyDB = OpenDatabase(App.Path & "\db4.mdb", , , ";PWD=mypassword")

If you're using ADO:
  See hiteshgupta1's example above
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

910 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now