The information in this article applies to:
Moderate: Requires basic macro, coding, and interoperability skills. This article applies to a Microsoft Access database (.mdb) and a Microsoft Access project (.adp). SYMPTOMSYou are unable to set the permissions for individual modules using the Security tools provided by Microsoft Access 2000. Permissions set to individual modules that were created in earlier versions of Access are ignored by Access 2000. CAUSEIn Access 2000, you can no longer protect individual modules using Microsoft Jet security. The Visual Basic Environment provides protection only on a per project basis. The Visual Basic Environment cannot protect individual modules. RESOLUTION
You can use one of two methods to protect code in your Visual Basic project. You can lock the project for viewing and assign a password. Or you can create an MDE or ADE file from the source database or Microsoft Access project file. Locking the Project for ViewingThe Visual Basic Environment enables you to protect the Visual Basic project of an Access database or Access project file by locking it for viewing and assigning a password to it. This will only allow users who know the password to view and modify your Visual Basic code, project properties, and references. To lock your Visual Basic project for viewing and to assign a password, follow these steps:
Creating an MDE/ADE FileCAUTION: 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.Saving your database or Access project file as an MDE or ADE file compiles all modules, removes all editable source code, and compacts the destination database. Your Visual Basic for Applications code continues to run, but it cannot be viewed or edited, and the size of your database will be smaller because the source code will be removed. To save your database or Access project file as an MDE or ADE file, follow these steps:
Protecting Only Certain ModulesEven though you cannot protect just certain modules within the Visual Basic project in the Visual Basic Environment, there is a strategy that you can use to accomplish this task. If you want some modules to be protected while others are not, determine which modules you want to protect and move them into an external Visual Basic project, and leave the modules that you want to leave unprotected in the original project. You can do this by creating a new Access database or Access project file, exporting the modules that you want to protect to that file, and then deleting those modules from the original Visual Basic project.Then you can use one of the two methods discussed earlier to protect the external Visual Basic project. Afterwards, you can add a library reference to the protected Visual Basic project. Note that a limitation to this approach is that you will not be able to directly instantiate class modules stored in the referenced project. MORE INFORMATION
A Visual Basic project is the set of all code modules, library references, and associated properties stored within an Access database or Access project file. In earlier versions of Access, if you wanted to view or edit a particular Visual Basic module, Access only had to retrieve that one module from the database's Visual Basic project and load it into the Visual Basic editor used by Access. If you edited that module and saved it, Access only had to save the changes to that particular module. Therefore, Access only had to read and write modules on an individual basis. This enabled Access to grant or deny permissions to individual modules, rather than to the entire Visual Basic project.
Steps to Reproduce Behavior
REFERENCESFor more information about creating code libraries, in the Visual Basic Editor, click
Microsoft Visual Basic Help on the Help menu, type "code libraries" in
the Office Assistant or the Answer Wizard, and then click Search to
view the topic. Additional query words: prb
Keywords : kbdta |
Last Reviewed: July 6, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |