[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to open password protected Access database?

Posted on 1998-09-02
18
Medium Priority
?
323 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 
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 40 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

831 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