Chris2 said:
Stuart,
SELECT M1.*
FROM MyTable AS M1
INNER JOIN
MyTable AS M2
ON M1.PrimaryKey = M2.PrimaryKey
WHERE M1.Customer = M2.Customer
AND (M1.TransactionDate
BETWEEN
(M2.TransactionDate - 2)
AND
(M2.TransactionDate + 2)
This is untested . . . just a guess on my part.
Sincerely,
Chris O.
Thanks again for the replies. This is what happened........
===========================================
Chris's suggestion:
After a bit of trial and error this was the best I could do, and it
returns all records.
SELECT M1.*, M1.namesID, M1.transdate
FROM TBL_TRANSACTIONS AS M1 INNER JOIN TBL_TRANSACTIONS AS M2 ON
M1.transactionID = M2.transactionID
WHERE (((M1.namesID)=[M2].[namesID]) AND ((M1.transdate) Between
[M2].[transdate]-2 And [M2].[transdate]+2));
============================================
John's suggestion
This works fine but, as indicated, it excludes duplicates with the
same date, which I'd like to include if possible. I've tried tinkering
with the criteria but I then get all records returned.
SELECT DateDiff("d",[TBL_TRANSACTIONS].[transdate],[TBL_TRANSACTIONS_1].[transdate])
AS DaysBetween, TBL_TRANSACTIONS.transdate, TBL_TRANSACTIONS.namesID,
TBL_TRANSACTIONS.amount
FROM TBL_TRANSACTIONS INNER JOIN TBL_TRANSACTIONS AS
TBL_TRANSACTIONS_1 ON (TBL_TRANSACTIONS.amount =
TBL_TRANSACTIONS_1.amount) AND (TBL_TRANSACTIONS.namesID =
TBL_TRANSACTIONS_1.namesID)
WHERE (((DateDiff("d",[TBL_TRANSACTIONS].[transdate],[TBL_TRANSACTIONS_1].[transdate]))
In (-2,-1,1,2)));
============================================
The Access Wizard gives me same day only duplicates
SELECT DISTINCTROW TBL_TRANSACTIONS.transdate,
TBL_TRANSACTIONS.namesID
FROM TBL_TRANSACTIONS
WHERE (((TBL_TRANSACTIONS.transdate) In (SELECT [transdate] FROM
[TBL_TRANSACTIONS] As Tmp GROUP BY [transdate],[amount],[namesID]
HAVING Count(*)>1 And [amount] = [TBL_TRANSACTIONS].[amount] And
[namesID] = [TBL_TRANSACTIONS].[namesID])))
ORDER BY TBL_TRANSACTIONS.transdate, TBL_TRANSACTIONS.namesID;
=============================================
I hope there's a combination somewhere in here that will work. Thanks
for the help so far.