View records by associated user id

PaulJK

Registered User.
Local time
Today, 07:11
Joined
Jul 4, 2002
Messages
60
I have placed this under General, although it covers queries, forms and security.

I have a database where clients are assigned to different sales people.

Currently all sales staff can only enter new client details only. There security profile consequently opens the client form in Data Entry mode.

Now for each sales person we need to give then access to their own client records only. I know I could have the query for the client form prompt for the Salesperson ID, but the wiser user could enter other ID's and see other salespersons client records.

Could someone give me some pointers on how I could resolve this. I am sure this is not an uncommon problem but cannot find any previous posts.

Thank you.
 
I agree that there must be a way but I do not know of it. Have you thought of adding the persons user ID to the client record and then limiting the query to view clients by ID. This way they would not need to enter there own ID as it would pick it up from the network (There is code somewhere on this site for retrieving someones network ID)
 
Here is the code!:

Function fOSUserName() As String
'Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If lngX <> 0 Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = ""
End If
End Function
 
You can use Harry's code to append the username to each record the users create then use the Function as criteria in a query that only picks up the records that belong to that userName.

Col
:cool:
 

Users who are viewing this thread

Back
Top Bottom