Being a Newbie!

B

bmacrow

Ok, i think im being a bit of a newbie here!

I am trying to get a form to show an extra button if a user logs in and is
part of the 'admins' group. I am using access 2000 and have user level
security enabled.

In the load event of the form i have the following code:

'Private Sub Form_Open(Cancel As Integer) '
'Select Case GBL_UserGroup
'
'Case "Admins"
'Me.userman.Visible = True
'
'Case Else
'Me.userman.Visible = False
'
'
'
'End Select
'
'End Sub

Now this i code i found on the net and as you have probably guessed it dont
work!
i think the problem with the code rests at select case GBL_usergroup as that
is placeholder stuff possibly reffering to a table where user levels are
kept, but cos i have user level security i dont have such a table. Am i
missing a fundamental thing here, or is there an easy swap? .....HELP GURUS
:)

Thanks in advance

Ben
 
G

Graham Mandeno

Hi Ben

The following function will tell you whether of not a given user (the
current user by default) is in a given group:

Function IsUserInGroup(strGroup As String, _
Optional strUser As String) As Boolean
Dim usr As Object
On Error Resume Next
If Len(strUser) = 0 Then strUser = CurrentUser
Set usr = DBEngine(0).Groups(strGroup).Users(strUser)
IsUserInGroup = Err = 0
End Function

You can then say something like:
If IsUserInGroup("Admins") Then ...
 

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