Question : microsoft access query criteria to retrieve specific records based on a reference number and part number

I have a query in my attached database.  When the database opens, a form opens with two part numbers listed.  What I want my query to return is all the records with "ReferenceNumber" that have BOTH these part numbers associated with the reference number.  I do not want to see a "ReferenceNumber" that may have either or of these part numbers.  Therefore the output will be reference numbers that show both (pair) of the part numbers listed on the form.  Please help.  Thanks.

Answer : microsoft access query criteria to retrieve specific records based on a reference number and part number

SELECT Distinct a.RefNumber, a.PartNo, b.RefNumber, b.PartNo
FROM dbo_CrfPartDetails AS a INNER JOIN dbo_CrfPartDetails AS b ON a.RefNumber = b.RefNumber
WHERE (((InStr([a].[PartNo],[Forms]![zz]![aa]))=1) AND ((InStr([b].[PartNo],[Forms]![zz]![bb]))=1))
ORDER BY a.RefNumber;


Lists 541.  There were obviously several cases of actual data where there were two or more records having the same RefNumber for the same set of PartNos's.  Making it distinct got rid of the duplications.
Random Solutions  
 
programming4us programming4us