Group:  Microsoft Access ยป microsoft.public.access.security
Thread: Record level access

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Record level access
Vanessa Jennings 12.07.2006 15:21:02
anyone know how I can give certain users access only to certain records
within a database...too many forms and reports to redo for each user!...
Re: Record level access
Scott McDaniel <scott[ at ]NoSpam_Infotrakker.com> 13.07.2006 01:50:07
On Wed, 12 Jul 2006 08:21:02 -0700, Vanessa Jennings <VanessaJennings[ at ]discussions.microsoft.com> wrote:

[Quoted Text]
>anyone know how I can give certain users access only to certain records
>within a database...too many forms and reports to redo for each user!...

Enable User Level Security, add appropriate users and groups, allow access to the data only through your forms (i.e.
don't allow users direct access to the tables or queries), then filter the data based on user logins and group
membership. For example, if you have a DataEntry group who shouldn't see data relevant to Managers (which is indicated,
perhaps, by setting a table column named blnIsManager=True), then you'd something like this if the Open or Load event of
a form:

Sub Form_Open()

If faq_IsUserInGroup("DataEntry", CurrentUser) Then
Me.RecordSource = "SELECT Field1, Field2 etc FROM SomeTable WHERE blnIsManager=False"
Else
Me.RecordSource = "SELECT Field1, Field2 etc FROM SomeTable"
End If

End Sub

'/Note: the below was copied from the MS Access Security FAQ here:
http://support.microsoft.com/?id=148555http://support.microsoft.com/default.aspx?scid=%2Fsupport%2Faccess%2Fcontent%2Fsecfaq.asp

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


Scott McDaniel
scott[ at ]takemeout_infotrakker.com
www.infotrakker.com
Re: Record level access
Vanessa Jennings 13.07.2006 07:34:01
ok thanks for this, will give it a go!

"Scott McDaniel" wrote:

[Quoted Text]
> On Wed, 12 Jul 2006 08:21:02 -0700, Vanessa Jennings <VanessaJennings[ at ]discussions.microsoft.com> wrote:
>
> >anyone know how I can give certain users access only to certain records
> >within a database...too many forms and reports to redo for each user!...
>
> Enable User Level Security, add appropriate users and groups, allow access to the data only through your forms (i.e.
> don't allow users direct access to the tables or queries), then filter the data based on user logins and group
> membership. For example, if you have a DataEntry group who shouldn't see data relevant to Managers (which is indicated,
> perhaps, by setting a table column named blnIsManager=True), then you'd something like this if the Open or Load event of
> a form:
>
> Sub Form_Open()
>
> If faq_IsUserInGroup("DataEntry", CurrentUser) Then
> Me.RecordSource = "SELECT Field1, Field2 etc FROM SomeTable WHERE blnIsManager=False"
> Else
> Me.RecordSource = "SELECT Field1, Field2 etc FROM SomeTable"
> End If
>
> End Sub
>
> '/Note: the below was copied from the MS Access Security FAQ here:
> http://support.microsoft.com/?id=148555http://support.microsoft.com/default.aspx?scid=%2Fsupport%2Faccess%2Fcontent%2Fsecfaq.asp
>
> 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
>
>
> Scott McDaniel
> scott[ at ]takemeout_infotrakker.com
> www.infotrakker.com
>
Re: Record level access
"Joan Wild" <jwild[ at ]nospamtyenet.com> 13.07.2006 13:38:39
Scott McDaniel wrote:
[Quoted Text]

You need to use
http://support.microsoft.com/?id=207793 as the above link has been removed.


--
Joan Wild
Microsoft Access MVP


Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net