Query using fOSUserName

Locopete99

Registered User.
Local time
Yesterday, 21:59
Joined
Jul 11, 2016
Messages
163
Hi,

I am trying to write a query that looks up the current user and returns all records where that person is the salesman.

My attempt is below, where i assumed that it would be easy enough to use a Dlookup in the criteria.

Can you nudge me in the right direction?

Code:
SELECT Tbl_ShikomiRegister.[Blanket Agreement Number], Tbl_ShikomiRegister.Salesman, Tbl_ShikomiRegister.[Part  Number], Tbl_ShikomiRegister.[Months to run out]
FROM Tbl_ShikomiRegister
WHERE (((Tbl_ShikomiRegister.Salesman)=DLookUp("[User Name]","Tbl_User","[login]= '" & "fOSUserName" & "'")));
 
You shouldn't use a Dlookup in a query - as it is effectively another query - use a join.

So add your user table joined by user name to salesmen name, and put the fOSUsername as the criteria for the login field in the users table.
 
Thanks Minty
 

Users who are viewing this thread

Back
Top Bottom