Solved

How to open password protected Access database?

Posted on 1998-09-02
18
313 Views
Last Modified: 2010-04-30
Hi, I want to open a password protected MS Access file from VB. How can I do that without using ODBC.
Waiting for help...
0
Comment
Question by:Moin
18 Comments
 
LVL 14

Expert Comment

by:waty
ID: 1432499
  DBEngine.SystemDB = "C:\yoursystemmdw.mdw"

   'Create a new workspace object
   'gwWorkSpace is a Global variable where you put in the module
   'txtUserName and txtPassword are fields on Logon screen.
   '
   Set gwWorkSpace = DBEngine.CreateWorkspace("New", _
   Trim(txtUserName.Text), Trim(txtPassword.Text), dbUseJet)

0
 

Author Comment

by:Moin
ID: 1432500
I can't understand your answer. What if I don't want to use workspace and if I am opening database directly using opendatabase. e.g.,
set godbHMC = opendatabase(dbPath)
How can I do this.

0
 
LVL 14

Expert Comment

by:waty
ID: 1432501
When you open directly your DB, you use a default workspace.

You have to create a workspace other than the default, with only the password.
0
 

Author Comment

by:Moin
ID: 1432502
But I have just password protected the database, I have no userName for the database.
0
 
LVL 14

Expert Comment

by:waty
ID: 1432503
In that case I think you have to use the default user (probably admin). Otherwise, create a user.
0
 
LVL 1

Expert Comment

by:soeding
ID: 1432504
Answer also to me, please.
0
 

Author Comment

by:Moin
ID: 1432505
My problem is still unsolved. Please tell me in detail ad each and every step to do this.
0
 
LVL 14

Expert Comment

by:waty
ID: 1432506
First : Create a user in your Access DB with a password :
         User     = "BillClinton"
         Password = "Monica"

Second : You have to create an new workspace :
   DBEngine.SystemDB = "C:\yoursystemmdw.mdw"

   'Create a new workspace object
   Set gwWorkSpace = DBEngine.CreateWorkspace("New", _
   "BillClinton", "Monica", dbUseJet)

Third : Open your database :
   set godbHMC = gwWorkSpace.opendatabase(dbPath)
 

0
 

Author Comment

by:Moin
ID: 1432507
When I use your suggested answer, I get the error
"Can't start your application. The workgroup information file is missing or opened exclusively by another user."
In my case none of the above situation exists.
What should I do now?
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 14

Expert Comment

by:waty
ID: 1432508
Wich version of Access do you use? If it is access 2.0, it is a MDA file.
0
 

Author Comment

by:Moin
ID: 1432509
It is Access 97.
0
 
LVL 14

Expert Comment

by:waty
ID: 1432510
Is your .MDW file exists?
0
 

Author Comment

by:Moin
ID: 1432511
Yes it exists in "C:\winnt\system32\system.mdw"
0
 

Author Comment

by:Moin
ID: 1432512
Yes it exists in "C:\winnt\system32\system.mdw"
0
 
LVL 14

Expert Comment

by:waty
ID: 1432513
Are you sure that Access is not open when you test your application?
0
 

Author Comment

by:Moin
ID: 1432514
yes, it's not open
0
 

Accepted Solution

by:
azupancic earned 10 total points
ID: 1432515
In order to open a password protected database via DAO, you need to supply all the information in the connect string when you open the database.  The connect string is semi-colon delimited, but what help doesn't tell you, is that even though Access is the default db type, you don't supply that portion of the connect string, i.e, you omit it, thus beginning your connect string with a semi-colon.

The sample below illustrates this:

Set db = OpenDatabase("MyDB.MDB", False, False, ";pwd=password")

Hope this helps.
0
 

Author Comment

by:Moin
ID: 1432516
Yes, that's great.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

757 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

20 Experts available now in Live!

Get 1:1 Help Now