prevent new objects

T

tracktraining

Hi All,

I want to prevent users from creating new objects in my database. I found
the code below in the SECFAQ doc.

Function faq_NoNew (strUser as String)

Dim db As Database
Dim con As Container

Set db = DBEngine(0)(0)
Set con = db.Containers("Tables")
con.UserName = strUser
con.Permissions = con.Permissions And Not DB_SEC_CREATE
End Function

Then I changed it around to the way I want, but of course the syntax is
wrong. I am getting the window login name, then look for the user access
level (i.e. User, Admin, SuperUser) which is stored in a table. If User or
admin, then don’t allow new objects; if SuperUser, then allow new objects.


Function faq_NoNew(strUser As String)

Dim db As Database
Dim con As Container
Dim strGetAccess As String

strGetAccess = "SELECT AccessLev FROM EmpInfo WHERE EmpInfo.EmpEmail =
'" + GetComputerName + "'"

Set db = CurrentDb()
Set con = db.Containers(strGetAccess)

'con.Username = strUser
con.Username = rs!AccessLev

If con.Username = "User" or con.Username = Admin Then
con.Permissions = con.Permissions And Not dbSecCreate
Else
con.Permissions = con.Permissions Or dbSecCreate
End If

End Function

I am getting the following error: Run-time error: 3265: item not found in
this collection. Pointing to the line Set con = db.Containers (strGetAccess).

Is there a way to get this to work? Or any other suggestions? Recommendation?

Thanks,
Tracktraining
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top