How to join two tables with relationship

Yes, I did.
Your attachment is beyond my knowledge in MS Access.
I will try to add some fields in the table tblFacilityRegister, and I will let you know how it helps.

Thanks a lot for your kind efforts.

All you need to do is copy & paste the query SQL into your database!

Code:
SELECT tblFacilityRegister.ID, tblFacilityRegister.SenderID, tblFacilityRegister.ReceiverID, tblFacilityRegister.ScannedBy, [tblSenders].[FirstName] & ' ' & [tblSenders.LastName] AS SenderName, [tblReceivers].[FirstName] & ' ' & [tblReceivers].[LastName] AS ReceiverName, [tblScanners].[FirstName] & ' ' & [tblScanners].[LastName] AS ScannedByName
FROM ((tblUsers AS tblSenders INNER JOIN tblFacilityRegister ON tblSenders.UserID = tblFacilityRegister.SenderID) INNER JOIN tblUsers AS tblReceivers ON tblFacilityRegister.ReceiverID = tblReceivers.UserID) INNER JOIN tblUsers AS tblScanners ON tblFacilityRegister.ScannedBy = tblScanners.UserID;

What's difficult about that?
Here's the same query in design view

attachment.php


The 3 tables tblSenders, tblReceivers, tblScanners are 3 copies of tblUsers where I've used an alias to distinguish them
 

Attachments

  • QueryDesign.PNG
    QueryDesign.PNG
    36 KB · Views: 223
Last edited:
If all three FK fields are defined as required, this query will be fine but if they are not defined as required, then the joins need to be left joins.
 
If all three FK fields are defined as required, this query will be fine but if they are not defined as required, then the joins need to be left joins.

I'd already stated about using outer vs inner joins back in posts 2 & 5.
However, as the OP has decided its all too difficult, it makes no difference anyway!
 
Last edited:
Thank you all for your responses, I got it solved by added Users to the Relationships window three times as " The_Doc_Man " recommended, then I did the same in the query too but I changed the Join Properties option 3.

Thanks again to all for interactions, specifically " ridders " I tried the code you provided I got some issues I do not know from where actually but I if I built my database perfectly it will work for sure.

Best Regards,
Alhakeem1977
 
Glad you got it solved .... but what you did sounds exactly like the solution I provided earlier - see post 21
 
Glad you got it solved .... but what you did sounds exactly like the solution I provided earlier - see post 21
Thanks, I see I'm new in MS Access that's why I can't understand many concepts, you are so advanced.

Thank you very much.
 

Users who are viewing this thread

Back
Top Bottom