Re: load a filtered form based on user login



Joan,

Still not working. I'm getting compile error; User defined type not defined

This is the code in which I based the module

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

When the error occurs the
Dim ws As WorkSpace is selected

I think this is getting over my head

Joan Wild wrote:
Joan,

[quoted text clipped - 8 lines]
or could I simply copy and paste it into the onopen event of the
form? I really appreciate your patience with this novice.

Create a new module and copy and paste the faq_IsUserInGroup code from the
security FAQ which you can download from
http://support.microsoft.com/?id=207793
Save the module giving a different name than the function.

Then in the On Open property for your form, choose Event Procedure, and then
click on the build button (...) Between the two lines put the following:

If faq_IsUserInGroup("Supervisors",CurrentUser) then
Me.RecordSource = "SELECT * FROM Time***"
Else
Me.RecordSource = "SELECT * FROM Time*** WHERE [EmployeeID] = " &
chr(34) & CurrentUser() & chr(34)
End If

Watch for newsreader wrap on the second Me.RecordSource line - it's all on
one line. Go to Debug menu and choose Compile - you should get no errors
(if you do post back). Then click on the save button. Close this window
and try your form.


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-tablesdbdesign/200608/1

.