To debug it, add this line after the "bIsAlpha = ..." line:
Debug.Print bIsAlpha
Then after setting Label150, add:
Debug.Print Me.Lable150.Visible
After opening the form, press Ctrl+G to open the Immediate Window, and see
if it is saying these things are True.
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Reply to group, rather than allenbrowne at mvps dot org.
SFC Traver said:
Okay, so I have the function in the General Declarations of the form.
Then I have the Visible property for Label150 set to No
Then I put in the form load:
Private Sub Form_Open(Cancel As Integer)
Dim bIsAlpha As Boolean
bIsAlpha = IsUserInGroup(CurrentUser(), "Alpha")
Me.Label150.Visible = bIsAlpha
But the Label is still hidden when I log in as a member of the Alpha
group.
Whats wrong?
Allen Browne said:
Yes that's the idea.
It would be better call the function just once though:
Dim bIsAlpha As Boolean
bIsAlpha = IsUserInGroup(CurrentUser(), "Alpha")
Me.[SomeControl2Show4AlphaUsersOnly].Visible = bIsAlpha
etc.
Thanks. Just to make sure I understand, I should use the Function you
built
in the OnOpen Form, and then for each control/label that I want to
limit I
would say:
If IsUserInGroup(CurrentUser(), "Alpha") Then DoCmd.Visible
Right or wrong?
:
This function should return True if the user is a member of the group:
Function IsUserInGroup(strUser As String, strGroup As String) As
Boolean
Dim varDummy As Variant
On Error Resume Next
varDummy = DBEngine(0).Users(strUser).Groups(strGroup).Name
IsUserInGroup = (Err.Number = 0)
End Function
Example:
If IsUserInGroup(CurrentUser(), "Alpha") Then ...
I have some command buttons and labels that I only want to be seen by
people
that are part of the "Alpha" group I set up in the Security. Is
there a
way
to do this?