Find Duplicates Query

AlexanderBB

Well-known Member
Joined
Jul 1, 2009
Messages
1,835
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
I tried the query wizard for this, but it works on one field. I need to join 2 fields together then check for duplicates. I did change the Field in query design to 'LC: [Label] & [Number]'
then used LC as the field name, but no luck.
Is there another way without making a new table with those 2 fields already joined?

Thanks.
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Thanks Denis. Interesting... I did end up finding this


SELECT f2, f3 FROM myTable GROUP BY f2, f3 HAVING COUNT(*) >1

seems to work OK. But now struggling over another problem.
A field called "Serial" in my table has a underscore delimiter. I want to select where the left Part length is 2.
In query design I'm putting 2 in Criteria and in Field

Len(Split([Serial],"_")(0))

Its going to error, but the syntax is OK and gives right answer testing it in immediate window.

Any thought, workaround for that ?

Thanks.




</pre>
 
Upvote 0
Glad to see you found something. The differences between what I posted and the answer that you found are that the subquery method: (1) Shows the whole record and (2) lets you do something to the duplicates, leaving the original in the table.

As for the second question, Access can't use Split directly in a query. It's a VBA function, so you need to create a function to use it.

Two options to try:
1. Using other text functions -- Len(Left([Serial],InStr(1,[Serial],"_")-1))

2. Creating a custom function --
Put this in a new module.
Code:
Function StringParse(strIn As String, strDelim As String, intWhich As Integer) As String
    Dim x
    x = Split(strIn, strDelim)
    StringParse = x(intWhich)
End Function

Now use it like this in the query
Len(StringParse([Serial],"_",0))

This function lets you choose your delimiter, and which chunk you want. 0 is the first.

Denis
 
Upvote 0
Cool, thanks Denis. That was very helpful and I followed it all.. now we're all go !!
Rgds, ABB
 
Upvote 0

Forum statistics

Threads
1,214,548
Messages
6,120,141
Members
448,948
Latest member
spamiki

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top