Skip to content
Advertisement

Access – Add Left Join to Return Value Based on Primary Key (PK)

I need help querying a user name based on its primary key value in table.

Another user @gordon-linoff helped me create a query to pull the most recent NoteDate for every OpportunityID in a table. I wanted to expand this to provide the NotesUser, which is part of the same table as the other two elements.

My challenge is NotesUser returns the UserID (which is a PK) and not the UserName.

Here is an example. This code:

Produced this result:

enter image description here

NotesUser is the PK of a table called tblUsers, which contains two columns. ID and UserName

Here the code I’ve got so far

This code throws a syntax error in the FROM statement.

Update: Here is what the tblUsers looks like.

enter image description here

Advertisement

Answer

If I understand correctly, you can just add a LEFT JOIN. No subquery is necessary:

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement