Just started thinking about solutions that would be close, but not perfect.
SELECT AP.VendorNumber, AP.AmountPaid, AP.InvoiceNumber
FROM [Your Table] as AP
WHERE AP.VendorNumber in
(SELECT Tmp.VendorNumber, Tmp.AmountPaid
, Left(Tmp.InvoiceNumber,5)
FROM [Your Table] as Tmp
GROUP BY Tmp.VendorNumber, Tmp.AmountPaid
, Left(Tmp.InvoiceNumber,5)
HAVING Count(*) > 1
AND Tmp.AmountPaid = AP.AmountPaid
AND Left(Tmp.InvoiceNumber,5) = Left(AP.InvoiceNumber,5)
If I got that built correctly it should return duplicate records based
on Vendor Number, Amount and the first 5 characters of InvoiceNumber
being the same. Of course, you can change the 5 characters to 6 or 7 or
whatever the minimum length of the "normal" Invoice number is.
Hope this works for you. Sorry, it took so long for me to respond, but
I just was not seeing a PERFECT solution and then I figured that this
should let you get close.
'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================
John,
If the report can give me identical invoice amounts within each vendor, I
can use it to scan for invoice numbers that look similiar. They usually
stand out anyway in that the invoice number will have -1 or -* or some other
character added to the invoice field to make Oracle accept it. This should
be sufficient if we can't programmatically identify those records within each
vendor that have similiar invoice numbers.
Thanks,
Mark
:
Ok, the next step is to use the query you have built to show all the records
SELECT AP.*
FROM AP
WHERE AP.Vendor_Number & Ap.Invoice_Amount in
(SELECT Q.Vendor_Number & Q.Invoice_Amount FROM TheQuery)
That will probably be slow.
But the real problem is still the Invoice_Number being similar. I think
I need to rethink this problem if you are going to get decent performance.
I'll try to post back later with a better solution.
'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================
utahbiker7 wrote:
John,
I got the sql code entered as below: It narrows down the results from 400k
records to 41k. I don't believe they are all duplicates but it is hard to
see just what records it is choosing. The results only give me two fields -
the vendor number and invoice amount. Can you tell me how to get the other
fields to show with the results? I need the check_no, check_date and store
number to investigate the results to see if it is indeed a duplicate payment.
I appreciate your help.
SELECT AP.VENDOR_NUMBER, AP.INVOICE_AMOUNT
FROM AP INNER JOIN TMP ON (AP.INVOICE_NUM LIKE TMP.INVOICE_NUM & "*") AND
(AP.INVOICE_AMOUNT=TMP.INVOICE_AMOUNT) AND
(AP.VENDOR_NUMBER=TMP.VENDOR_NUMBER)
WHERE TMP.INVOICE_NUM IS NOT NULL
GROUP BY AP.VENDOR_NUMBER, AP.INVOICE_AMOUNT
HAVING COUNT(*)>1;
:
This might get you started.
SELECT AP.VendorNumber, AP.AmountPaid
FROM [Your Table] as AP
INNER JOIN [Your Table] As Tmp
ON AP.VendorNumber = Tmp.VendorNumber
AND AP.AmountPaid = Tmp.AmountPaid
AND AP.InvoiceNumber LIKE Tmp.InvoiceNumber & "*"
WHERE Tmp.InvoiceNumber is Not Null
GROUP BY AP.VendorNumber, AP.AmountPaid
Having Count(*) > 1
'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================
utahbiker7 wrote:
I have imported to 2007 Access our accounts payable history. I would like
to analysis the data to determine if we have made duplicate payments to a
vendor. I would like to query the database on vendor number. If within
the vendor number an invoice amount is identical I would like it flagged.
I would also like to narrow those records down to those have similar invoice
numbers. I have found that sometimes the processing of payments is forced
by changing the invoice number - like adding an additional digit to override
the software's controls and thus making a duplicate payment to a vendor.
So, if anyone can help me with a query to identify duplicate payments to a
vendor, I would appreciate it. It has been a long time since I've used
access but I remember at one time it could identify dups... thanks.