O'Reilly logo

Beginning Access™ 2007 VBA by Denise Gosnell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

12.3. Securing Your Application

You have various ways to add security to your application. You can implement one or more of these techniques, depending on the type of security that is required for your application. For example, you can assign passwords to the database and/or to the code, and you can encrypt the database. Let's look at each of these concepts in more detail.

12.3.1. Adding a Database Password

One way to add security to your database is to require a user to input a password before the database can be opened. This is called file-level security. After the database file has been opened by specifying the correct password, the user can do anything to the database unless the other security features are implemented.

You have at least two ways to set a database password. One way is to select the Database Tools ribbon Encrypt with Password option. You will be prompted to enter a password for the database. Another way to set a database password is programmatically using VBA code. For example, you can execute SQL statements against the database to set, change, and remove a database password. Here are sample SQL statements for each of these options:

'SQL statement for setting password for first time (from NULL to some value) strSQL = "ALTER DATABASE PASSWORD [newpassword] NULL" 'SQL statement for changing the database password strSQL = "ALTER DATABASE PASSWORD [anotherpassword] ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required