ACC: Using DAO to Open Password-Protected Database (95/97)Last reviewed: September 11, 1997Article ID: Q161016 |
The information in this article applies to:
SUMMARYModerate: Requires basic macro, coding, and interoperability skills. This article demonstrates how to use the OpenDatabase method to open a Microsoft Access database that has a database password. Note that this is different from opening a database that is secured with the Microsoft Access user-level security feature. This article assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Visual Basic for Applications, please refer to your version of the "Building Applications with Microsoft Access" manual.
MORE INFORMATIONIf you want to use the OpenDatabase method to open a password-protected database, specify the database password as part of the Connect argument. The syntax to open a database with the OpenDatabase method is as follows:
Set db = workspace.OpenDatabase(dbname, options, read-only, connect)NOTE: Even though the Options and Read-Only arguments of the OpenDatabase method are documented in Help as being optional arguments, you must provide them when you use the Connect argument. If you use a Connect argument and you do not provide the Options and Read-Only arguments, you receive run-time error 3031 "Not a valid password." This occurs even if the password that you provided in the Connect argument is correct. If you do not need to use a Connect argument, then you can omit the Options and Read-Only arguments. When you use the OpenDatabase method to open a password-protected Microsoft Access database, the Connect argument of the OpenDatabase method requires the following syntax:
"MS Access;pwd=<password>"The following example uses the OpenDatabase method to open the sample database Northwind.mdb, which is protected with a database password of "northwind." CAUTION: Following the steps in this example will modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and perform these steps on a copy of the database.
REFERENCESFor more information about the OpenDatabase method, search the Help Index for "OpenDatabase method." For more information about database passwords, search the Help Index for "passwords, database," or ask the Microsoft Access 97 Office Assistant.
|
Additional query words: pwd secure
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |