Re: Txt and users levels?



<d9pierce@xxxxxxxxx> wrote in message
news:92c3ab51-4731-4496-8660-732176c6193f@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi all,
Is there a way to display on forms a message "You have permission to
unlock records" & "You do not have permission to unlock records"
depending on user levels?

Yes, when you open the form, in the forms on-load event you could put the
following code:

if IsInGroup(CurrentUser,"SuperUser" then

me.txtMsg = "You have permission to unlock records"

else

me.txtMsg = "You have permission to unlock records"

end if

The above example assumes you have a un-bound text box on the form called
txtMsg, and the user is a member of the security group called "SuperUser".
Of course you replace "SuperUser" with the name you used for the security
group that a person is a member of that allows edits (and, change the name
of txtMsg to the name of the text box you choose on your form.

The funciton IsInGroup is not built into ms-access, but the code for that is
easy. Simply place the follow code in a standard public module (not the
forms module)

Public Function IsInGroup(UsrName As String, GrpName As String) As Boolean
'Determines whether UsrName is a member of a security group 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


--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pleaseNOOSpamKallal@xxxxxxx


.



Relevant Pages

  • Re: Txt and users levels?
    ... 'Determines whether UsrName is a member of a security group GrpName ...     Dim grp As Group ...     Dim IIG As Boolean ...
    (microsoft.public.access.formscoding)
  • Re: VBScript runtime error: 800A0046 Permission denied: GetObject
    ... Can you get it to echo the strDomain, strUserName values? ... Dim SMSNetwork ... "Domain Admins") Then MapLDrive = FALSE ... Directory I need to go to re-establish permission. ...
    (microsoft.public.windows.server.active_directory)
  • Re: security/strong name/zones clarification needed
    ... Dim zz As New System.Security.PermissionSet ... >> When assemblies are ... >>>needs to host the CLR, it creates an AppDomain, but due ... >>>will recieve the permission grant you expect (in this ...
    (microsoft.public.dotnet.security)
  • Re: Read Exchange calendar with a VB script
    ... I thought it might be a permission ... Is there any other way to access the mailboxes ... > Dim objSession As MAPI.Session ... > Dim objMessages As MAPI.Messages ...
    (microsoft.public.win32.programmer.messaging)
  • Re: Fax printer inaccessible
    ... Give "Print" permission to the security group on the shared fax printer. ... If it is a local user, it goes as anonymous to the server. ... >> with the default security settings, even if you have faxing permissions ...
    (microsoft.public.win2000.fax)