To get the user name, do you use the currentuser, or did you created a
variable called user?
In any case, you can put a code break in the If statement to view the value
of user, or the current user, and you can step the code by pressing the F8
key, to see what happen.
If you use the currentuser provided by access then change the user to
currentuser, in the IF statement.
It's an earlier post to get the groups which the user is in, just add the
criteria for the group you looking for and return true with the function to
determine if the fields should be displayed
'----- start of code -----
Function fncUserGroups() As String
' Returns a comma-separated list of the security groups of which
' the current user is a member.
' NOTE: Requires a reference to the DAO Object Library.
Dim ws As DAO.Workspace
Dim grp As DAO.Group
Dim strGroups As String
Set ws = DBEngine.Workspaces(0)
fncUserGroups =false
For Each grp In ws.Users(CurrentUser).Groups
If grp.Name = "admin" Then
fncUserGroups = True
exit function
end if
Next grp
Set ws = Nothing
fncUserGroups = Mid(strGroups, 3)
End Function
'----- start of code -----
Then you could set the ControlSource of your text box to
If fncUserGroups() Then
me.button.visible=false
else
me.button.visible=true
endif
Well, it seems like it always takes two times form me to get things right.
I'm sure I'm doing something wrong here but I pasted that code into a module
and then, as a test, set fncUserGroups() as control source for a text box but
it doesn't return any data... any ideas?