Link to home
Start Free TrialLog in
Avatar of Moin
Moin

asked on

How to open password protected Access database?

Hi, I want to open a password protected MS Access file from VB. How can I do that without using ODBC.
Waiting for help...
Avatar of waty
waty
Flag of Belgium image

  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)

Avatar of Moin
Moin

ASKER

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.

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.
Avatar of Moin

ASKER

But I have just password protected the database, I have no userName for the database.
In that case I think you have to use the default user (probably admin). Otherwise, create a user.
Answer also to me, please.
Avatar of Moin

ASKER

My problem is still unsolved. Please tell me in detail ad each and every step to do this.
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)
 

Avatar of Moin

ASKER

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?
Wich version of Access do you use? If it is access 2.0, it is a MDA file.
Avatar of Moin

ASKER

It is Access 97.
Is your .MDW file exists?
Avatar of Moin

ASKER

Yes it exists in "C:\winnt\system32\system.mdw"
Avatar of Moin

ASKER

Yes it exists in "C:\winnt\system32\system.mdw"
Are you sure that Access is not open when you test your application?
Avatar of Moin

ASKER

yes, it's not open
ASKER CERTIFIED SOLUTION
Avatar of azupancic
azupancic

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Moin

ASKER

Yes, that's great.