Get current user access rights

M

mike

I need a way to set the visibility of a form control based on the current
users permissions to read a particular table. What would be the simples
and/or best way to do this?

something like ...

If .......Then ' Can read table
tabUpdateForm.Visible = True
Else
tabUpdateForm.Visible = False
End If

Thanks

Mike
 
A

Albert D. Kallal

If IsInGroup(currentUser(),"deleteInvoiceGroup") = True then


The code for the above is:

Public Function IsInGroup(UsrName As String, GrpName As String) As Boolean
'Determines whether UsrName is a member of GrpName

Dim grp As Group
Dim IIG As Boolean
Dim usr As user

IIG = False

For Each usr In DBEngine.Workspaces(0).Users
If usr.Name = UsrName Then GoTo FoundUser
Next

GoTo IIG_Exit

FoundUser:
For Each grp In usr.Groups
If grp.Name = GrpName Then IIG = True
Next

IIG_Exit:
IsInGroup = IIG


End Function
 
M

mike

Thanks for the reply.

I'd rather avoid needing to query whether the user belongs to a specific
group as group names could be changed or added. I really want to now if the
current users has access to a particlar table or form.

Mike
 
T

TC

untested:

dim db as database, td as tabledef
set db = currentdb()
set td = db.tabledefs![MyTable]
td.user = currentuser() ' probably not required.

' At this point, td.AllPermissions holds the bitmask of permissions
' that the current user has to the table in question; either directly,
' or by virtue of group membership. Read online help for
' AllPermissions to see how you interpret it. Then when
' finished:

set td = nothing
set db = nothing

HTH,
TC
 

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