Allowing only certain user Groups to change a combo box

S

Sam

Hello All learned people

I need to prevent a combo box (Called Lender) from being altered once a
"Lender" has been selected. This is easy enough, however I want to give
certain user groups the ability to be able to change the lender if need be.
The user groups that I want to have access to do this are:-

Admins
Teamleader

Can anyone assist me??

Cheers
 
D

Dirk Goldgar

Sam said:
Hello All learned people

I need to prevent a combo box (Called Lender) from being altered once
a "Lender" has been selected. This is easy enough, however I want to
give certain user groups the ability to be able to change the lender
if need be. The user groups that I want to have access to do this
are:-

Admins
Teamleader

I'm assuming that the groups in question are those establish by
user-level (workgroup) security. Paste this function into a standard
module:

'----- start of function code -----
Function fncUserIsInGroup(GroupName As String) As Boolean

' Returns True if the current user is a member of the specified
' security group; False if not, or if the group doesn't exist, or
' if an error occurs reading the groups.

Dim ws As Workspace

Set ws = DBEngine.Workspaces(0)

On Error Resume Next
fncUserIsInGroup = _
(ws.Users(CurrentUser).Groups(GroupName).Name = GroupName)

Set ws = Nothing

End Function
'----- end of function code -----

Then in the form's Current event, put code like this:

'----- start of code for Current event -----
Private Sub Form_Current()

With Me!Lender

.Enabled = _
IsNull(.Value) Or _
fncUserIsInGroup("Admins") Or
fncUserIsInGroup("Teamleader")

.Locked = Not .Enabled

End With

End Sub
'----- end of code for Current event -----
 
D

Dirk Goldgar

Sam said:
Dirk

What if they were not created by User Level Security Wizard?

If you're not using user-level security (whether created by the wizard
or manually), then what defines the groups, how do you know who is the
current user, and how do you know what groups a user belongs to? Have
you built this user/group structure and logic?
 
Top