I have a car repair business.
The header table is the "order" table with the customers name and address etc.
The detail is each part number used in the repair.
When the part number is unknown I use a dummy part code of "999".
However,I cannot flag an "order" as complete IF it has any details part number of "999".
SELECT Count(*) AS CountMissingNumbers, tblDetail.CustomerID
GROUP BY tblDetail.[windowcode], tblDetail.CustomerID
HAVING (((tblDetail.[windowcode])="999") AND ((tblDetail.CustomerID)=[forms]![job1]![CustomerID]));
See snippet of code which checks for part number ="999".
Question: How do I "embed" this SQL into my VBA?
For purposes of the example, let's say I have a button on the order header which says "Complete Order". This button calls my SQL check (and rejects the command if there are any 999's)