Find Duplcate values in 1 field for each customer

S

Steve

I have a table called Orders. It contains Fields called
CustId, OrderNumber, OrderDate, ShipDate amongst many
other fields.

I need to find Only the records that contain Duplicate
Values in the OrderDate Field for each CustId.

i.e. If CustID #001 has two records with an Order Date of
12/01/03 then both records are to be displayed. If a
CustID does not have a matching record with the same
Order Date then No records are to be displayed.

So my query result should look something like:
CUSTID ORDERID ORDERDATE
0001 12345 12/01/02
0001 12399 12/01/02
0007 12447 01/02/03
0007 21554 01/02/03
0007 35878 01/02/03


Any help would be appreciated. Thank you.
..
 
A

Allen Browne

1. Create a query into your Orders table.

2. Depress the Total button (toobar).
Access adds a Total row to the grid.

3. Drag CustID and OrderDate into the query grid.
Accept "Group By" in the Total row.

4. Drag OrderID into the grid.
Choose Count in the Total row.
In the Criteria row, enter:

5. Save the query with a name such as "qryOrderDupe"

6. Create another query, using the first one as an input "table" as well as
the Orders table.

7. Drag qryOrderDupe.CustID onto Orders.CustID.
Drag qryOrderDupe.OrderDate onto Orders.OrderDate.

8. Drag the 3 fields you want to see from the Orders table into the output
grid.

This works because the first query selects only the customers and dates that
have duplicates, and it then limits the output of the 2nd query.

Hint: If you are just troubleshooting, you might be content to stop at step
3. Then drag OrderId into the grid twice, choosing Min and Max in the Total
row. This shows you the lowest OrderID and the highest OrderID for the
duplicate orders which is all you need for the cases where there are only
two.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top