By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,495 Members | 1,208 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,495 IT Pros & Developers. It's quick & easy.

Please help me with limiting user view

P: n/a
I've developed a database that will be used by my team (25 people)
The database is based on the Resource Planner template

The database will reside on a shared drive.
What I'd to do now is create some sort of entry point into the
database that only shows the users records they own.

So I was thinking when the database opens the user selects their name.
Then the switchboard opens but no matter what they select from the
switchboard only records that have the same name as the name selected
at open will be displayed.

I don't need any sort of password protect

How should I do this?

Thanks
Steve J
Oct 24 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Oct 24, 12:22*pm, Steve <dafella...@yahoo.comwrote:
I've developed a database that will be used by my team (25 people)
The database is based on the Resource Planner template

The database will reside on a shared drive.
What I'd to do now is create some sort of entry point into the
database that only shows the users records they own.

So I was thinking when the database opens the user selects their name.
Then the switchboard opens but no matter what they select from the
switchboard only records that have the same name as the name selected
at open will be displayed.

I don't need any sort of password protect

How should I do this?

Thanks
Steve J
create a table called tblUser
userId autonumber pk
userName
userLogin
create a module called mNtuser, to get their windows login containing,
this

Option Compare Database
Option Explicit

Declare Function GetUserName& Lib "advapi32.dll" Alias
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long)

Public Function ntUserName() As String
Dim s$, cnt&, dl&, sz&

cnt& = 255
s$ = String$(255, vbNullChar)
dl& = GetUserName(s$, cnt&)
If (Asc(Mid$(s$, cnt&, 1)) = 0) Then
cnt& = cnt& - 1
End If

ntUserName = UCase(Left$(s$, cnt&))
End Function
public function userId as long
userId = nz(dlookup("userId","tblUser","userLogin = '" &
ntusername() & "'"),-1)
end function
use = userId() in all your queries as a condition on the userId field
to return all records belonging to that user
Oct 24 '08 #2

P: n/a
On Oct 24, 1:49*pm, Roger <lesperan...@natpro.comwrote:
On Oct 24, 12:22*pm, Steve <dafella...@yahoo.comwrote:


I've developed a database that will be used by my team (25 people)
The database is based on the Resource Planner template
The database will reside on a shared drive.
What I'd to do now is create some sort of entry point into the
database that only shows the users records they own.
So I was thinking when the database opens the user selects their name.
Then the switchboard opens but no matter what they select from the
switchboard only records that have the same name as the name selected
at open will be displayed.
I don't need any sort of password protect
How should I do this?
Thanks
Steve J

create a table called tblUser
* * userId * autonumber pk
* * userName
* * userLogin

create a module called mNtuser, to get their windows login containing,
this

Option Compare Database
Option Explicit

Declare Function GetUserName& Lib "advapi32.dll" Alias
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long)

Public Function ntUserName() As String
* * Dim s$, cnt&, dl&, sz&

* * cnt& = 255
* * s$ = String$(255, vbNullChar)
* * dl& = GetUserName(s$, cnt&)
* * If (Asc(Mid$(s$, cnt&, 1)) = 0) Then
* * * * cnt& = cnt& - 1
* * End If

* * ntUserName = UCase(Left$(s$, cnt&))
End Function

public function getUserId as long
* *userId = nz(dlookup("userId","tblUser","userLogin = '" *&
ntusername() & "'"),-1)
end function

use = userId() in all your queries as a condition on the userId field
to return all records belonging to that user- Hide quoted text -

- Show quoted text -
Steve
in response to your email, I'll post here so others can participate

The tbluser has the person's name and windows login (ntlogin)

If you don't know their windows login, you need to use ms-access
workgroup security, or have no security

Just having users select their name from a list is not a good idea,
cause I can choose your name, and see your records

since I don't have your table layout, I don't know how you identify
who records belong to who, I'm assuming it's an ID of some sort...
that ID and userId in tblUser is the same

the function ntUserName() gets your windows login
the function getUserId (I've renamed it from just 'userId') translates
the windows login to an ID that can be used to select records

so if your table is called tblResource with
resourceId autonumber pk
userId
resource

your query would be
SELECT * FROM tblResource WHERE userId = userId()

if I'm logged in, this will show my resources
and if you're logged in, yours
hope this helps
Oct 24 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.