I have a Access 2016 database which I am trying to design. I have a table with a roster of people tblRoster, a 1-1 relationship to another table with Basic Individual Data about the the person and 1-1 relationship from this basic data table to another table as lookup. I have a working query but when I add a column from the lookup table no data is shown. Please help figure out why.
Please find below the the SQL Statement for the query:
SELECT tblRoster.EDIPI, [tblRoster].[LastName] & ", " & [tblRoster].[FirstName] & " " & Left$([tblRoster].[MiddleName],1) AS [Full Name], tblBasicIndividualRecords.PriMilOccSpec AS MOS, DLookUp("LongName","tblMilitaryOccupationalSpecialties","tblMilitaryOccupationalSpecialties!ID = " & [tblBasicIndividualRecords].[PriMilOccSpec]) AS [MOS Decription], DLookUp("Abbreviation","tblRankStructure","tblRankStructure!ID = " & [tblRoster].[Rank]) AS Rank, Format([EndOfActiveService],"yymmdd") AS EAS, tblBasicIndividualRecords.Billet, tblBasicIndividualRecords.OnHand, tblBasicIndividualRecords.Remarks, tblBasicIndividualRecords.Deployable, tblRankStructure.SortValue
FROM (tblRankStructure INNER JOIN tblRoster ON tblRankStructure.ID = tblRoster.Rank) INNER JOIN tblBasicIndividualRecords ON tblRoster.EDIPI = tblBasicIndividualRecords.EDIPI
ORDER BY tblRankStructure.SortValue DESC;
When I add the lookup table to the query no data populates:
SELECT tblRoster.EDIPI, [tblRoster].[LastName] & ", " & [tblRoster].[FirstName] & " " & Left$([tblRoster].[MiddleName],1) AS [Full Name], tblBasicIndividualRecords.PriMilOccSpec AS MOS, DLookUp("LongName","tblMilitaryOccupationalSpecialties","tblMilitaryOccupationalSpecialties!ID = " & [tblBasicIndividualRecords].[PriMilOccSpec]) AS [MOS Decription], DLookUp("Abbreviation","tblRankStructure","tblRankStructure!ID = " & [tblRoster].[Rank]) AS Rank, Format([EndOfActiveService],"yymmdd") AS EAS, tblBasicIndividualRecords.Billet, tblBasicIndividualRecords.OnHand, tblBasicIndividualRecords.Remarks, tblBasicIndividualRecords.Deployable, tblRankStructure.SortValue, tblMilitaryOccupationalSpecialties.SortOrder
FROM tblMilitaryOccupationalSpecialties INNER JOIN ((tblRankStructure INNER JOIN tblRoster ON tblRankStructure.ID = tblRoster.Rank) INNER JOIN tblBasicIndividualRecords ON tblRoster.EDIPI = tblBasicIndividualRecords.EDIPI) ON (tblMilitaryOccupationalSpecialties.ID = tblBasicIndividualRecords.AddMilOccSpec.Value) AND (tblMilitaryOccupationalSpecialties.ID = tblBasicIndividualRecords.PriMilOccSpec)
ORDER BY tblRankStructure.SortValue DESC;