Query ! Duplicate records in column "x" and the values recorded in the respective col (1 Viewer)

mfaqueiroz

Registered User.
Local time
Today, 15:09
Joined
Sep 30, 2015
Messages
125
Query ! Duplicate records in column "x" and the values recorded in the respective col

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...

State Code
Open 3
Open 3
Close 4
Close 6

Open 5


I tried to use the vba, but didn't worked...(i used the followed code)

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
 

plog

Banishment Pending
Local time
Today, 17:09
Joined
May 11, 2011
Messages
11,653
Re: Query ! Duplicate records in column "x" and the values recorded in the respective

You didn't provide enough sample data. Please tell me what should be returned from this data set:

State, Code
Open, 1
Open, 1
Open, 2
Open, 3
Closed, 2
Closed, 2
Closed, 4
Closed, 4
Closed, 6
Closed, 7
 

Users who are viewing this thread

Top Bottom