
'how to open an password protected access mdb file
Here is one way of doing it. I'm opening my databases with code. A lot of
programmers prefer to use a ADO datacontrol, or ADO Dataenvironment. Here is
the code version. This one uses a dataenvironment, but the connectionstring
is set during opening of the database. In other words, the connection
properties is not set in the dataenvironment property pages.
db.conn.Open ("Provider=Microsoft.Jet.OLEDB.4.0;User ID=user;Password=
******;Data Source= " & Location & " ;Persist Security Info=False;Jet
OLEDB:System database=mydatabasedrive\mydatabsepath\mydatabasegroupfile.mdw)
Location is a variable that contains the path to the database file (.mdb
file).
Note:
If you just password protect your database, it'll not be possible to open it
from VB. Now, I may be wrong on that, and anybody that knows better is
welcome to correct me.
Anyway:
The code above opens a database where you have created a group security
file. The connection string needs the "system database" statement if your
group file is not the default group file for Access. The default file is
named "System.mdw" and is usually located in "c:\program files\common
files\system".
If you set your connection properties in the property pages of the
dataenvironment, you'll have to go to the "ALL" tab and set the system
database location there.
If you plan on distributing your application, then you'll need to make a new
groupfile and distribute it along with it. Make sure it is not named
"system.mdw" as it may interfere with the users existing rights when he/she
installs your program.
To create a group file:
Run "C:\Program Files\Microsoft Office\Office\1033\WRKGADM.EXE"
Create a NEW file, and locate it to your app.path.
Then fire up Access and open the database you wanna secure.
Run the "Security-Level Wizard" under the "Tools->Security" menu.
During this session, create an account for yourself.
MAKE SURE THE ACCOUNT IS ASSIGNED TO THE ADMIN GROUP!
Restart Access and open your database.
You'll be propted for username and password.
Enter a username that you created during the security wizard session.
The user account does not have a password yet, so leave it blank.
As soon as you're in, start the "user and group accounts" under
"Tools->Security", and set the password. You can only set password for the
user that is logged in.
That's it. Now you have a secured database, that will open with the code
above.
That was easy. Don't you think :-)
Good luck
Ivar
Quote:
> I am new in vb and don't know how to use vb program to open a password
> protected access mdb file, anybody can tell me or email a sample code .
> thanks in advance