Filter a Subform by current User

Locopete99

Registered User.
Local time
Today, 07:25
Joined
Jul 11, 2016
Messages
163
Good Morning,

I have a subform that is running off of the below query

Code:
SELECT Tbl_ReqType.ID, Tbl_ReqType.[Part Number], Tbl_ReqType.[Assigned To]
FROM Tbl_ReqType
WHERE (((Tbl_ReqType.[Assigned To])="Customer Care") AND ((Tbl_ReqType.Complete)=False)) OR (((Tbl_ReqType.[Assigned To])="jmorris") AND ((Tbl_ReqType.Complete)=False)) OR (((Tbl_ReqType.[Assigned To])="lpurser") AND ((Tbl_ReqType.Complete)=False));

I also am using the fOSUserName code by Dev Ashish to find the current user

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 = vbNullString
    End If
End Function

On my subform I have the field "Assigned To".

I have about 40 people using this form. but I want each user to only see their own records on the subform, so where the user on the database is the same as the fOSUserName (all users are done by the windows login, so should be the same as fOSUserName.)

Now as there are 40 people using this, i dont want the fOSUserName to be the criteria on the query, I just want to be able to filter the subform.

How would I do this??
 
Just to follow up - each user has their own copy of the Front End, and multiple users can be using this at the same time. I want to filter the subform where Assigned to = fOSUserName.
 
The logical solution is adding the function to the criteria. Why don't you want to do that? Since each user has their own copy, it wouldn't affect other users.
 
I might be being thick about this.

I have spent some time running subforms from a delete and update table.

I keep forgetting that the queries would be on their standalone front end and unaffected by anyone else.
 

Users who are viewing this thread

Back
Top Bottom