OK, it's official! I have no clue what I am trying to do 
Lets see if I can explain it. I am trying to get a report of all Open cases based on the highest priority. I can't figure out how to get only the max value to show. I created a query to find all open batches. I then take that query and create a new query adding the Priority information. How do I limit the second query (or even combine them into just one query) so that only the highest priority shows up? The following are my queries:
QryAllOpenBatchs:
SELECT tblBatchNo.BatchNoID, tblBatchNo.BatchNo, tblProduct.ProdID, tblProduct.ProdCode, tblSKU.SKUNo, tblSKUFillLines.FilledUnits, tblSKUFillLines.FilledGals
FROM ((tblProduct INNER JOIN (tblBatchNo INNER JOIN tblBatchNoProduct ON tblBatchNo.BatchNoID = tblBatchNoProduct.BatchNoID) ON tblProduct.ProdID = tblBatchNoProduct.ProdID) INNER JOIN tblSKU ON tblProduct.ProdID = tblSKU.ProdID) INNER JOIN tblSKUFillLines ON tblSKU.SKUID = tblSKUFillLines.SKUID
WHERE (((tblSKUFillLines.FilledUnits) Is Null)) OR (((tblSKUFillLines.FilledGals) Is Null));
QryOpenBatchesBasedOnPriority:
SELECT P.[PriorityCodeID],C.[PriorityCode], B.[BatchNoID], B.[BatchNo], B.[ProdID], B.[ProdCode], B.[SKUNo], P.[DaysAvailable]
FROM (tblPriorityCode C
INNER JOIN tblProductPriorityCode P ON C.[PriorityCodeID] = P.[PriorityCodeID])
INNER JOIN QryOpenBatches B ON P.[BatchNoID] = B.[BatchNoID]
WHERE P.PriorityCodeID IN
(Select MAX(P1.PriorityCodeID)
From tblPriorityCode C1 INNER JOIN tblProductPriorityCode P1
ON C.[PriorityCodeID] = P.[PriorityCodeID]
Where C1.[PriorityCodeID] = C.[PriorityCodeID]
AND P1.[PriorityCodeID] = P.[PriorityCodeID] )
ORDER BY B.[BatchNo], B.[ProdNo];
I get a syntax error on this second query in the WHERE clause.
Any help would be greatly appreciated!
Brenda
Lets see if I can explain it. I am trying to get a report of all Open cases based on the highest priority. I can't figure out how to get only the max value to show. I created a query to find all open batches. I then take that query and create a new query adding the Priority information. How do I limit the second query (or even combine them into just one query) so that only the highest priority shows up? The following are my queries:
QryAllOpenBatchs:
SELECT tblBatchNo.BatchNoID, tblBatchNo.BatchNo, tblProduct.ProdID, tblProduct.ProdCode, tblSKU.SKUNo, tblSKUFillLines.FilledUnits, tblSKUFillLines.FilledGals
FROM ((tblProduct INNER JOIN (tblBatchNo INNER JOIN tblBatchNoProduct ON tblBatchNo.BatchNoID = tblBatchNoProduct.BatchNoID) ON tblProduct.ProdID = tblBatchNoProduct.ProdID) INNER JOIN tblSKU ON tblProduct.ProdID = tblSKU.ProdID) INNER JOIN tblSKUFillLines ON tblSKU.SKUID = tblSKUFillLines.SKUID
WHERE (((tblSKUFillLines.FilledUnits) Is Null)) OR (((tblSKUFillLines.FilledGals) Is Null));
QryOpenBatchesBasedOnPriority:
SELECT P.[PriorityCodeID],C.[PriorityCode], B.[BatchNoID], B.[BatchNo], B.[ProdID], B.[ProdCode], B.[SKUNo], P.[DaysAvailable]
FROM (tblPriorityCode C
INNER JOIN tblProductPriorityCode P ON C.[PriorityCodeID] = P.[PriorityCodeID])
INNER JOIN QryOpenBatches B ON P.[BatchNoID] = B.[BatchNoID]
WHERE P.PriorityCodeID IN
(Select MAX(P1.PriorityCodeID)
From tblPriorityCode C1 INNER JOIN tblProductPriorityCode P1
ON C.[PriorityCodeID] = P.[PriorityCodeID]
Where C1.[PriorityCodeID] = C.[PriorityCodeID]
AND P1.[PriorityCodeID] = P.[PriorityCodeID] )
ORDER BY B.[BatchNo], B.[ProdNo];
I get a syntax error on this second query in the WHERE clause.
Any help would be greatly appreciated!
Brenda