Enabling/Disabling Controls based on User Groups

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello everyone,
I have a form that includes invoice collection information. This form is to
be used by the cheque collectors to fill in the cheques data and by their
supervisor to revise the entries and post them.
My aim is to add a "Post" button on the form that can only be enabled when
the supervisor logs on.
is it possible to perform this, knowing that my databse is client/server
(BE and FE) and uses a workgroup information file for security.
thanks
 
Hello everyone,
I have a form that includes invoice collection information. This form is to
be used by the cheque collectors to fill in the cheques data and by their
supervisor to revise the entries and post them.
My aim is to add a "Post" button on the form that can only be enabled when
the supervisor logs on.
is it possible to perform this, knowing that my databse is client/server
(BE and FE) and uses a workgroup information file for security.
thanks

You can determine group membership like this:

Function faq_IsUserInGroup (strGroup As String, strUser as String) As Integer
' Returns True if user is in group, False otherwise
' This only works if you're a member of the Admins group.
Dim ws As WorkSpace
Dim grp As Group
Dim strUserName as string

Set ws = DBEngine.Workspaces(0)
Set grp = ws.Groups(strGroup)
On Error Resume Next
strUserName = ws.groups(strGroup).users(strUser).Name
faq_IsUserInGroup = (Err = 0)
End Function

So you'd do this in the form's Open or Load event:

Me.YourButton.Enabled = faq_IsUserInGroup("SupervisorGroup",CurrentUser)

Code snipped from the MS Access ULS FAQ:
http://support.microsoft.com/default.aspx?scid=/support/access/content/secfaq.asp#_Toc493299691

Scott McDaniel
scott@takemeout_infotrakker.com
www.infotrakker.com
 

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

Back
Top