|
Question : Access security query
|
|
I have a multi-user secure access database with 2 usergroups set up.
I have some VBA code that does an import using DAO, however, if a user tries to run this routine without the correct permissions then the code locks up.
Is there anyway for me to check in code that the user has permissions before I run the code.
A more simpler method would be to disable the command button on the form if the user is not in the correct group. This will stop the code being run.
Any advice would be a big help.
Lee
|
|
Answer : Access security query
|
|
Here's one idea. In the OnOpen event or some other trigger point add code similiar to this:
Dim db As Database Dim wk As Workspace Dim blFlag As Boolean blFlag = False Set wk = DBEngine.Workspaces(0) Dim gp As Group Set gp = wk.Groups("Test") 'This should be the name of the Group that HAS permission Dim usr As User For Each usr In gp.Users 'This looks at the name of the users in the specified group If CurrentUser = usr.Name Then 'Then compares them to the current user blFlag = True Exit For End If Next If blFlag = True Then Command1.Visible = True ' The name of the command button that holds the code for execution Else Command1.Visible = False End If
|
|
|