Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

ACC2000: How to Prevent Users from Creating New Databases


View products that this article applies to.

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.

↑ Back to the top


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:

  1. 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.
  2. Start Microsoft Access, and then open the sample database Northwind.mdb.
  3. Create a new user named TestUser as a member of the Users group.
  4. Add a password for the Admin user.
  5. Create a new module, and then type the following line in the Declarations section if it is not already there:
    Option Explicit
  6. 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
    					
  7. On the View menu, click Immediate Window.
  8. In the Immediate window, type the following line, and then press ENTER:
    ?Remove_DBCreate()
  9. Quit Microsoft Access, and then restart it.
  10. 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.
  11. Log in as TestUser.
  12. 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.
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.

↑ Back to the top


References

For more information about permissions, click Microsoft Access Help on the Help menu, type work with permissions in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

↑ Back to the top


Keywords: KB210329, kbusage, kbinfo, kbhowto

↑ Back to the top

Article Info
Article ID : 210329
Revision : 3
Created on : 1/26/2005
Published on : 1/26/2005
Exists online : False
Views : 349