Show/Hide objects based on Security Groups

G

Guest

With my split, multi-user, secured Access 2000 db, I have 3 user groups -
Admins, Read-Only, and Full-User (built-in groups). I'd like to disable or
hide some command buttons I have on my switchboard - "User Maintenance", and
"Change Password" for all but Admins. I have code that finds out which group
the logged-in user belongs to, but it doesn't allow the non-Admin users to
run it:
strUserLevel = Workspaces(0).Users(Workspaces(0).UserName).Groups(0).Name
so I can't hide or show objects based on the user level.
- Is this by design, or is there a way to do this?
 
J

Joan Wild

You may find it easier if you create your own unbound form for your
switchboard. It is more flexible than the built-in switchboard manager,
especially for something like this.

There is code in the security FAQ you can use to determine if a user is
member of a group.

Then in the open event of your menu form you'd use...

If faq_IsUserInGroup("ReadOnly",CurrentUser) then
Me.cmdWhatever.Visible = False
Me.cmdSomething.Visible = True
etc.
Else
Me.cmdWhatever.Visible = True
Me.cmdSomething.Visible = True
etc.
End If

The FAQ can downloaded from
http://support.microsoft.com/?id=207793
 
G

Guest

I'm still getting error 3112: Record cannot be read. No Read permission on
MSysGroupList. I tried both 'faq_ListGroupsofUser' and 'faq_IsUserInGroup'.
It works fine with Admins, but not with the other groups.

jp
 
G

Guest

Here's my code - it's pretty straightforward:

Private Sub cmdOK_Click()
On Error GoTo errhnd

Dim wsp As DAO.Workspace
Dim usr As DAO.User
Dim strUserName As String

strUserName = Application.CurrentUser

If Me.txtNewPassword = Me.txtConfirmPassword Then
Set wsp = DAO.Workspaces(0)
Set usr = wsp.Users(strUserName)
usr.NewPassword Me.txtOldPassword, Me.txtNewPassword
Else
MsgBox "Re-enter your Passwords. Your NewPassword
doesn't match your ConfirmPassword", vbInformation + vbOKOnly, "Passwords
don't Match"
- etc etc - assorted code to check for pwd length, etc is removed.

you're right - I can't find MSysGroupList or MSysUserList in the system
tables. The closest I come is MSysGroups in the mdw file.
??
jp
 
G

Guest

OK - I'll investigate. There may be something hidden somewhere in the db
that's keeping me up at night.

jp
 
G

Guest

OK - I removed all security, imported everything into a new db and reset the
security and it all works like a champ. Something got corrupted somewhere
and I couldn't recover from it. I've since recovered and am doing well.
 

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