Can't figure this one out. I have a left table with field "Product". I have a right table also with field "Product", but also many other fields.
If I left join on "Product", I want all products from left table to show. If no match in right table, I want nulls. Has worked a dozen times before. But now, it's leaving out one product for some reason.
Here's the sql:
SELECT tbl_EMSetal_ProdRef.Product, Count(tbl_pending_queue_historical.cur_amount) AS [Count], Sum(nz([cur_amount],0)) AS Amount
FROM tbl_EMSetal_ProdRef LEFT JOIN tbl_pending_queue_historical ON tbl_EMSetal_ProdRef.Product = tbl_pending_queue_historical.txt_product
WHERE (((tbl_pending_queue_historical.txt_department)="PIRS" Or (tbl_pending_queue_historical.txt_department) Is Null) AND ((tbl_pending_queue_historical.ysn_exclude)=0 Or (tbl_pending_queue_historical.ysn_exclude) Is Null) AND ((tbl_pending_queue_historical.dte_reporting_month ) Is Null Or (tbl_pending_queue_historical.dte_reporting_month) =[Forms]![FormMaster]![RepMo]))
GROUP BY tbl_EMSetal_ProdRef.Product;
Funny thing is....if I copy the left table just for the records where dte_reporting_month = the date from the form, and do the query on that copied table, then it works.
If I left join on "Product", I want all products from left table to show. If no match in right table, I want nulls. Has worked a dozen times before. But now, it's leaving out one product for some reason.
Here's the sql:
SELECT tbl_EMSetal_ProdRef.Product, Count(tbl_pending_queue_historical.cur_amount) AS [Count], Sum(nz([cur_amount],0)) AS Amount
FROM tbl_EMSetal_ProdRef LEFT JOIN tbl_pending_queue_historical ON tbl_EMSetal_ProdRef.Product = tbl_pending_queue_historical.txt_product
WHERE (((tbl_pending_queue_historical.txt_department)="PIRS" Or (tbl_pending_queue_historical.txt_department) Is Null) AND ((tbl_pending_queue_historical.ysn_exclude)=0 Or (tbl_pending_queue_historical.ysn_exclude) Is Null) AND ((tbl_pending_queue_historical.dte_reporting_month ) Is Null Or (tbl_pending_queue_historical.dte_reporting_month) =[Forms]![FormMaster]![RepMo]))
GROUP BY tbl_EMSetal_ProdRef.Product;
Funny thing is....if I copy the left table just for the records where dte_reporting_month = the date from the form, and do the query on that copied table, then it works.