Microsoft KB Archive/210329

= ACC2000: How to Prevent Users from Creating New Databases =

Article ID: 210329

Article Last Modified on 1/26/2005

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q210329



Advanced: Requires expert coding, interoperability, and multiuser skills.

This article applies only to a Microsoft Access database (.mdb).



SUMMARY
This article describes how to use the security constant dbSecDBCreate to prevent database users from creating new databases. This constant can be set and removed only with Visual Basic for Applications code.



MORE INFORMATION
When you negate the security constant dbSecDBCreate for a user, you remove that user's permission to create new databases. The following example demonstrates how to use the dbSecDBCreate constant to remove the permission to create new databases from all users in the Users group:

 Quit Microsoft Access if it is running. Copy the System.mdw file, which is usually in the \Program Files\Microsoft Office\Office folder, and save it as a file with another name. For example, copy the file and save it as System.bak. Start Microsoft Access, and then open the sample database Northwind.mdb. Create a new user named TestUser as a member of the Users group. Add a password for the Admin user. Create a new module, and then type the following line in the Declarations section if it is not already there:

Option Explicit

  Type the following code in the module. Function Remove_DBCreate

Dim d As DAO.Database, c As Container, SystemDB As String SystemDB = "C:\Program Files\Microsoft Office\" & _ "Office\System.mdw" ' Use path for your system. Set d = DBEngine(0).OpenDatabase(SystemDB) Set c = d.Containers!Databases c.UserName = "Users" c.Permissions = c.Permissions And Not dbSecDBCreate

End Function </li> On the View menu, click Immediate Window.</li> In the Immediate window, type the following line, and then press ENTER:

?Remove_DBCreate

</li> Quit Microsoft Access, and then restart it.</li> On the File menu, click New Database. Select Database, and then click OK. In the File Name box, type C:\db1.mdb, and then click Create.</li> Log in as TestUser.</li> On the File menu, click New Database. In the File Name box, type C:\db1.mdb, and then click OK. Note that you receive the following message:

You do not have the necessary permissions to use the 'C:\db1.mdb' object. Have your system administrator or the person who created this object establish the appropriate permissions for you.

</li></ol>

Note that if a member of the Users group has permission to create new databases by also belonging to another group (such as the Admins group), that user is still able to create new databases. Microsoft Access uses the most liberal permissions of the groups that a user belongs to.

<div class="references_section">