Get current user access rights

  • Thread starter Thread starter mike
  • Start date Start date
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
 
Look up the premissions property in VBA Help. I have not
used this for some time but think this is where you need
to start
 
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
 
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
 
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
 
Back
Top