Let's say I have a simple table, with the following format:
==================================
| ID | Invoice | Box | Delivered |
==================================
| 1 | AA11 | 1 | True |
----------------------------------
| 2 | AA11 | 2 | False |
----------------------------------
| 3 | AA22 | 1 | False |
----------------------------------
| 4 | AA33 | 1 | False |
----------------------------------
| 5 | AA44 | 1 | True |
----------------------------------
ID is a unique integer, Invoice is a TEXT field, Box is an Integer, and Delivered being a boolean (or BIT, as it's know in Access).
A query like this gets a list of everything that has been delivered:
SELECT * FROM Deliveries WHERE Delivered = True
However, each invoice can have multiple boxes (as is the case with invoice 1111), and sometimes not all the boxes are delivered at the same time. If a box has been delivered, I would like to be able to get the status of the other boxes with the same invoice number.
I know I can run multiple queries to do this. The one I mentioned above, and then another which loops through all the return results, and then runs another select with Invoice = ####.
Is there a way to do this all in a single query? I think it might be WHERE EXISTS, but I can't find out how to structure the query.
Ideally, I want the rows returned for a single query of the above able to be rows with ID's: 1, 2, and 5. This is the output I am looking for:
==================================
| ID | Invoice | Box | Delivered |
==================================
| 1 | 1111 | 1 | True |
----------------------------------
| 2 | 1111 | 2 | False |
----------------------------------
| 5 | 4444 | 1 | True |
----------------------------------
So that even though Delivered = False for ID 2, it is still returned because another item with the same invoice number has Delivered = True
When trying out some queries I got the error
Cannot join on memo, ole or hyperlink Object