S
saraqpost
I only found one post on this in MS Access (others in Paradox, Oracle).
The "solution" is to use a Left Join, which I am using, but I am not
getting the records to show where I have only a Master record and no
details.
Below is my query and the subset of Data that SHOULD show, but doesn't
is presented first.
Thanks!
Sara
TrailerInYardKey DateDropped TrailerNum FreightCoKey
90 6/9/2006 198 6
91 6/1/2006 1 7
92 8/1/2006 98A 18
Key 90 has 2 detail records on tblTrailerInYardDetails; Key 91 and 92
have 0 Details.
SELECT DISTINCT tblTrailerInYard.TrailerInYardKey,
tblTrailerInYard.DateDropped, tblTrailerInYard.TrailerNum,
tblFreightCo.FreightCo, tblTrailerInYard.TrailerInYardStatus,
tblTrailerInYard.WhseKey,
tblTrailerInYardDetails.TrailerInYardDetailsKey,
tblTrailerInYardDetails.KeyRecNum, IIf([PONum]=1," ",[PoNum]) AS PO,
IIf([tblPOInfo].[PONum]=1," ",[tblPOInfo].[CreditSalesTo] & "-" &
[DeptCategory]) AS Dept, tblTrailerInYardDetails.NumPallets,
tblTrailerInYard.UnloadDate, tblFreightCo.FreightCOKey,
tblTrailerInYardDetails.TrailerInYardDetailsStatus
FROM (tblFreightCo
RIGHT JOIN tblTrailerInYard ON tblFreightCo.FreightCOKey =
tblTrailerInYard.FreightCoKey) LEFT JOIN ((tblTrailerInYardDetails
LEFT JOIN tblPOInfo ON tblTrailerInYardDetails.POKey = tblPOInfo.POKey)
LEFT JOIN [Static Dept Data] ON tblPOInfo.CreditSalesTo = [Static Dept
Data].CreditSalesTo) ON tblTrailerInYard.TrailerInYardKey =
tblTrailerInYardDetails.TrailerInYardKey
WHERE (((tblTrailerInYard.TrailerInYardStatus)="A") AND
((tblTrailerInYard.WhseKey)=[Forms]![frmListTrailersDroppedInYard]![txtWhseKey])
AND ((tblTrailerInYardDetails.TrailerInYardDetailsStatus)="A"))
ORDER BY tblTrailerInYard.DateDropped DESC;
The "solution" is to use a Left Join, which I am using, but I am not
getting the records to show where I have only a Master record and no
details.
Below is my query and the subset of Data that SHOULD show, but doesn't
is presented first.
Thanks!
Sara
TrailerInYardKey DateDropped TrailerNum FreightCoKey
90 6/9/2006 198 6
91 6/1/2006 1 7
92 8/1/2006 98A 18
Key 90 has 2 detail records on tblTrailerInYardDetails; Key 91 and 92
have 0 Details.
SELECT DISTINCT tblTrailerInYard.TrailerInYardKey,
tblTrailerInYard.DateDropped, tblTrailerInYard.TrailerNum,
tblFreightCo.FreightCo, tblTrailerInYard.TrailerInYardStatus,
tblTrailerInYard.WhseKey,
tblTrailerInYardDetails.TrailerInYardDetailsKey,
tblTrailerInYardDetails.KeyRecNum, IIf([PONum]=1," ",[PoNum]) AS PO,
IIf([tblPOInfo].[PONum]=1," ",[tblPOInfo].[CreditSalesTo] & "-" &
[DeptCategory]) AS Dept, tblTrailerInYardDetails.NumPallets,
tblTrailerInYard.UnloadDate, tblFreightCo.FreightCOKey,
tblTrailerInYardDetails.TrailerInYardDetailsStatus
FROM (tblFreightCo
RIGHT JOIN tblTrailerInYard ON tblFreightCo.FreightCOKey =
tblTrailerInYard.FreightCoKey) LEFT JOIN ((tblTrailerInYardDetails
LEFT JOIN tblPOInfo ON tblTrailerInYardDetails.POKey = tblPOInfo.POKey)
LEFT JOIN [Static Dept Data] ON tblPOInfo.CreditSalesTo = [Static Dept
Data].CreditSalesTo) ON tblTrailerInYard.TrailerInYardKey =
tblTrailerInYardDetails.TrailerInYardKey
WHERE (((tblTrailerInYard.TrailerInYardStatus)="A") AND
((tblTrailerInYard.WhseKey)=[Forms]![frmListTrailersDroppedInYard]![txtWhseKey])
AND ((tblTrailerInYardDetails.TrailerInYardDetailsStatus)="A"))
ORDER BY tblTrailerInYard.DateDropped DESC;