J
Joan
I am still trying to figure out how to handle this.
I have an ItemDetails table and a sales order details table.
I need to do a stock short report but my problem is that the sale order might have a part that does not yet exist in the item details table (hasn't been received before).
I have a query:
SELECT tblSalelNoParts.SaleNo, Sum(tblSaleNoParts.Qty) AS SumOfQty, tblSaleNoParts.PartNo, tblSaleNoParts.EndType, Sum(tblItemDetail.Qty) AS SumOfQty1, IIf(Sum([tblItemDetail]![Qty])=Null,Sum([tblSaleNoParts]![Qty])-0,Sum([tblSaleNoParts]![Qty])-Sum([tblItemDetail]![Qty])) AS StockShortTest
FROM tblItemDetail RIGHT JOIN tblSaleNoParts ON tblItemDetail.ItemNo = tblSaleNoParts.PartNo
GROUP BY tblSalelNoParts.SalelNo, tblSalelNoParts.PartNo, tblSaleNoParts.EndType;
This gives me all parts from the SalesOrder and subtracts the qty from the qty on ItemDetails table. Where my problem is if the part isn't in the itemdetails table yet then itemdetails.Qty is null so I thought the IIf statement would handle that by subtracting 0 and giving me the result in StockShortTest but it just gives me a NULL result. Can I handle this here? Or do I need to create a 'dummy record' in the item details table with qty 0 (I don't want to do this as probably not good db design).
As always any help is appreciated.
Joan
I have an ItemDetails table and a sales order details table.
I need to do a stock short report but my problem is that the sale order might have a part that does not yet exist in the item details table (hasn't been received before).
I have a query:
SELECT tblSalelNoParts.SaleNo, Sum(tblSaleNoParts.Qty) AS SumOfQty, tblSaleNoParts.PartNo, tblSaleNoParts.EndType, Sum(tblItemDetail.Qty) AS SumOfQty1, IIf(Sum([tblItemDetail]![Qty])=Null,Sum([tblSaleNoParts]![Qty])-0,Sum([tblSaleNoParts]![Qty])-Sum([tblItemDetail]![Qty])) AS StockShortTest
FROM tblItemDetail RIGHT JOIN tblSaleNoParts ON tblItemDetail.ItemNo = tblSaleNoParts.PartNo
GROUP BY tblSalelNoParts.SalelNo, tblSalelNoParts.PartNo, tblSaleNoParts.EndType;
This gives me all parts from the SalesOrder and subtracts the qty from the qty on ItemDetails table. Where my problem is if the part isn't in the itemdetails table yet then itemdetails.Qty is null so I thought the IIf statement would handle that by subtracting 0 and giving me the result in StockShortTest but it just gives me a NULL result. Can I handle this here? Or do I need to create a 'dummy record' in the item details table with qty 0 (I don't want to do this as probably not good db design).
As always any help is appreciated.
Joan