Not sure I understand the issue.
If you just want to deduplicate the results you may be able to do that by
adding DISTINCT to the query (immediately after SELECT.)
If you have the same table in the main query and in the subquery, you may
need to alias one of them so Access knows which one you mean.
If that's not the issue, post your SQL statement.
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Reply to group, rather than allenbrowne at mvps dot org.
Allen
Thanks this worked wonderfully, however the powers that be now want to
be
able to set a date selection.
I have tried to include a date field [Analysis Date]in the selection
from
the table [items], but this returns all the records for the completed
batch,
when I want to avoid duplication of the records within the batch.
I was not aware of subqueries and the article was worthwhile. Could you
please give me a nudge in the right direction for the above problem
because
the big thrill (sad I know) is actually getting to the solution
yourself.
thanks
Richard
:
Use a subquery to check for any uncompleted Items.
Assuming you have:
- a table of Batches with a BatchID primary key
- a table of Items, with:
* a BatchID foreign key
* a Result field (blank until done)
then the query might look like this:
SELECT Batches.*
FROM Batches
WHERE NOT EXISTS (
SELECT BatchID FROM Items
WHERE Items.BatchID = Batches.BatchID
AND Items.Result Is Null)
If subqueries are new, here's a starting point:
Subquery basics
at:
http://allenbrowne.com/subquery-01.html
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Reply to group, rather than allenbrowne at mvps dot org.
Need to select records where a batch is completed
Batch is made up of "Items" which are complete when field [Result]
has
a
value in it.
I need my query to select batch numbers for which all "Items" are
completed
ignoring any part completed batches.
Any help greatly appreciated
Richard