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
- On the View menu, click Immediate Window.
- In the Immediate window, type the following line, and then press ENTER:
?Remove_DBCreate()
- Quit Microsoft Access, and then restart it.
- 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.
- Log in as TestUser.
- 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.