Query ! Duplicate records in column "x" and the values recorded in the respective column "y" shouldn't be equal...

mfaqueiroz

New Member
Joined
Sep 30, 2015
Messages
5
Hi, everyone!

I need an query that finds duplicate values in the column state but at same time the code of this records has to be different.

So my query should give me only the bold values...

StateCode
Open3
Open3
Close4
Close6
Open5

<tbody>
</tbody>

<tbody></tbody>


I tried to use the vba, but didn't worked...

Option Compare Database


Dim qdf As DAO.QueryDef
Dim StrSQL As String
Set qdf = CurrentDb.QueryDefs("LMt")
StrSQL = "In (SELECT [State] FROM [Tb_A] As Tmp GROUP BY [State] HAVING Count(*)>1 )" And "In (SELECT
Code:
 FROM [Tb_dispprotfinal] As Tmp GROUP BY [Code] HAVING Count(*)<>1 )"
qdf.SQL = StrSQL
Set qdf = Nothing

Could someone help me? 
:)

I really appreciate your time,
thank you
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
For starters, you need to provide the names of your tables and fields. Your example suggests you have one table, your sql suggests you have Tb_A and b_dispprotfinal. If there are two, there has to be a common field between them, so after you post the info, I'll see what I can do. The StrSQL you have just won't work that way.
 
Upvote 0

Forum statistics

Threads
1,221,841
Messages
6,162,314
Members
451,759
Latest member
damav78

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