Too many duplicate records

R

Ricoy-Chicago

Access XP. I have created a query to find duplicate records, no problem here.
Management wants to see duplicated records ONLY for the current calendar
year. I have a date field and used a criteria to restrict the fields to the
required dates, no problem here.

Problem: some records show only once because the data may exist in a
previuos year. For example if data was entered in June 2004 and then the same
data is entered in December 12, 2007 this is NOT considered a duplicated
record. However, if the data is entered on 1/1/07 and then again today, this
IS a duplicated record.

This query is used to generate a report, as you can imagine the report has a
lot of non-duplicated records.

Any help will be greatly appreciated.
 
K

KARL DEWEY

So in your query just use the year from the date ---
Format([YourDateField],"yyyy")
 
J

Jerry Whittle

Show us the SQL. Open the query in design view. Next go to View, SQL View
and copy and past it here.

Also provide examples of what you do and do not want to see returned by the
query.
 
J

Jerry Whittle

Show us the SQL. Open the query in design view. Next go to View, SQL View
and copy and past it here.

Also provide examples of what you do and do not want to see returned by the
query.
 
J

Jerry Whittle

Show us the SQL. Open the query in design view. Next go to View, SQL View
and copy and past it here.

Also provide examples of what you do and do not want to see returned by the
query.
 
R

Ricoy-Chicago

sorry about the delay... had to grab something to eat...
SQL:
SELECT [Prospect Students].[Date of Contact], [Prospect Students].[Last
Name], [Prospect Students].[First Name], [Prospect Students].SSN, [Prospect
Students].Address, [Prospect Students].[Lead Source], [Prospect
Students].[Staff Code]
FROM [Prospect Students]
WHERE ((([Prospect Students].[Date of Contact])>#1/1/2007#) AND (([Prospect
Students].[Last Name]) In (SELECT [Last Name] FROM [Prospect Students] As Tmp
GROUP BY [Last Name],[First Name] HAVING Count(*)>1 And [First Name] =
[Prospect Students].[First Name])))
ORDER BY [Prospect Students].[Date of Contact] DESC , [Prospect
Students].[Last Name], [Prospect Students].[First Name];

when I run the query, all the records have a 2007 date, there is no problem
with that but I have records that show only once because a duplicated record
exist back, let say on September 2006. So i don't want so see those.
 
K

KARL DEWEY

Trythis --
SELECT Format([Date of Contact],"yyyy") AS [Contact Year], [Prospect
Students].[Last Name], [Prospect Students].[First Name], [Prospect
Students].SSN, [Prospect Students].Address, [Prospect Students].[Lead
Source], [Prospect Students].[Staff Code], Count(Format([Date of
Contact],"yyyy")) AS Expr2
FROM [Prospect Students]
GROUP BY Format([Date of Contact],"yyyy"), [Prospect Students].[Last Name],
[Prospect Students].[First Name], [Prospect Students].SSN, [Prospect
Students].Address, [Prospect Students].[Lead Source], [Prospect
Students].[Staff Code]
HAVING (((Count(Format([Date of Contact],"yyyy")))>1));

--
KARL DEWEY
Build a little - Test a little


Ricoy-Chicago said:
sorry about the delay... had to grab something to eat...
SQL:
SELECT [Prospect Students].[Date of Contact], [Prospect Students].[Last
Name], [Prospect Students].[First Name], [Prospect Students].SSN, [Prospect
Students].Address, [Prospect Students].[Lead Source], [Prospect
Students].[Staff Code]
FROM [Prospect Students]
WHERE ((([Prospect Students].[Date of Contact])>#1/1/2007#) AND (([Prospect
Students].[Last Name]) In (SELECT [Last Name] FROM [Prospect Students] As Tmp
GROUP BY [Last Name],[First Name] HAVING Count(*)>1 And [First Name] =
[Prospect Students].[First Name])))
ORDER BY [Prospect Students].[Date of Contact] DESC , [Prospect
Students].[Last Name], [Prospect Students].[First Name];

when I run the query, all the records have a 2007 date, there is no problem
with that but I have records that show only once because a duplicated record
exist back, let say on September 2006. So i don't want so see those.

Jerry Whittle said:
Show us the SQL. Open the query in design view. Next go to View, SQL View
and copy and past it here.

Also provide examples of what you do and do not want to see returned by the
query.
 
R

Ricoy-Chicago

Thank you Karl, I'll try it tomorrow... time to call it quits at work...

KARL DEWEY said:
Trythis --
SELECT Format([Date of Contact],"yyyy") AS [Contact Year], [Prospect
Students].[Last Name], [Prospect Students].[First Name], [Prospect
Students].SSN, [Prospect Students].Address, [Prospect Students].[Lead
Source], [Prospect Students].[Staff Code], Count(Format([Date of
Contact],"yyyy")) AS Expr2
FROM [Prospect Students]
GROUP BY Format([Date of Contact],"yyyy"), [Prospect Students].[Last Name],
[Prospect Students].[First Name], [Prospect Students].SSN, [Prospect
Students].Address, [Prospect Students].[Lead Source], [Prospect
Students].[Staff Code]
HAVING (((Count(Format([Date of Contact],"yyyy")))>1));

--
KARL DEWEY
Build a little - Test a little


Ricoy-Chicago said:
sorry about the delay... had to grab something to eat...
SQL:
SELECT [Prospect Students].[Date of Contact], [Prospect Students].[Last
Name], [Prospect Students].[First Name], [Prospect Students].SSN, [Prospect
Students].Address, [Prospect Students].[Lead Source], [Prospect
Students].[Staff Code]
FROM [Prospect Students]
WHERE ((([Prospect Students].[Date of Contact])>#1/1/2007#) AND (([Prospect
Students].[Last Name]) In (SELECT [Last Name] FROM [Prospect Students] As Tmp
GROUP BY [Last Name],[First Name] HAVING Count(*)>1 And [First Name] =
[Prospect Students].[First Name])))
ORDER BY [Prospect Students].[Date of Contact] DESC , [Prospect
Students].[Last Name], [Prospect Students].[First Name];

when I run the query, all the records have a 2007 date, there is no problem
with that but I have records that show only once because a duplicated record
exist back, let say on September 2006. So i don't want so see those.

Jerry Whittle said:
Show us the SQL. Open the query in design view. Next go to View, SQL View
and copy and past it here.

Also provide examples of what you do and do not want to see returned by the
query.
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


:

Access XP. I have created a query to find duplicate records, no problem here.
Management wants to see duplicated records ONLY for the current calendar
year. I have a date field and used a criteria to restrict the fields to the
required dates, no problem here.

Problem: some records show only once because the data may exist in a
previuos year. For example if data was entered in June 2004 and then the same
data is entered in December 12, 2007 this is NOT considered a duplicated
record. However, if the data is entered on 1/1/07 and then again today, this
IS a duplicated record.

This query is used to generate a report, as you can imagine the report has a
lot of non-duplicated records.

Any help will be greatly appreciated.
 
J

John Spencer

I might try the following. Note that I changed the date comparison to >=
and calculated the date as January 1 of the current year using the
DateSerial function

SELECT [Prospect Students].[Date of Contact]
, [Prospect Students].[Last Name], [Prospect Students].[First Name]
, [Prospect Students].SSN, [Prospect Students].Address
, [Prospect Students].[Lead Source]
, [Prospect Students].[Staff Code]
FROM [Prospect Students]
WHERE [Prospect Students].[Date of Contact]>=DateSerial(Year(Date()),1,1)
AND [Prospect Students].[Last Name] In
(SELECT [Last Name]
FROM [Prospect Students] As Tmp
WHERE TMP.[Date of Contact] >=DateSerial(Year(Date()),1,1)
GROUP BY [Last Name], [First Name]
HAVING Count(*)>1
and [First Name] = [Prospect Students].[First Name])
ORDER BY [Prospect Students].[Date of Contact] DESC
, [Prospect Students].[Last Name], [Prospect Students].[First Name];

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

Ricoy-Chicago said:
sorry about the delay... had to grab something to eat...
SQL:
SELECT [Prospect Students].[Date of Contact], [Prospect Students].[Last
Name], [Prospect Students].[First Name], [Prospect Students].SSN,
[Prospect
Students].Address, [Prospect Students].[Lead Source], [Prospect
Students].[Staff Code]
FROM [Prospect Students]
WHERE ((([Prospect Students].[Date of Contact])>#1/1/2007#) AND
(([Prospect
Students].[Last Name]) In (SELECT [Last Name] FROM [Prospect Students] As
Tmp
GROUP BY [Last Name],[First Name] HAVING Count(*)>1 And [First Name] =
[Prospect Students].[First Name])))
ORDER BY [Prospect Students].[Date of Contact] DESC , [Prospect
Students].[Last Name], [Prospect Students].[First Name];

when I run the query, all the records have a 2007 date, there is no
problem
with that but I have records that show only once because a duplicated
record
exist back, let say on September 2006. So i don't want so see those.

Jerry Whittle said:
Show us the SQL. Open the query in design view. Next go to View, SQL
View
and copy and past it here.

Also provide examples of what you do and do not want to see returned by
the
query.
 
R

Ricoy-Chicago

Jerry's and Karl's SQL statement did not work. Thank you to both but Karl's
is closer to what I want but still is not the correct output. I am going to
try an example:

Case A. Joe Doe's information is entered on 9/9/05 and then it is re-entered
on 7/7/07. This is not a duplicated record on 2007.

Case B. Joe Doe's infromation is entered on 2/2/07 and then it is re-entered
on 10/31/07. This is a duplicated record for 2007.

For case B there is no problem.

For case A, the query should not show Joe Doe' records; however, the query
shows Joe doe once, because his data was entered on 9/9/05 (previous calndar
year) it is not a duplicated record in 2007. He should not appear at all.
That's what my problem is, I end with a lot of "single" records.

John Spencer said:
I might try the following. Note that I changed the date comparison to >=
and calculated the date as January 1 of the current year using the
DateSerial function

SELECT [Prospect Students].[Date of Contact]
, [Prospect Students].[Last Name], [Prospect Students].[First Name]
, [Prospect Students].SSN, [Prospect Students].Address
, [Prospect Students].[Lead Source]
, [Prospect Students].[Staff Code]
FROM [Prospect Students]
WHERE [Prospect Students].[Date of Contact]>=DateSerial(Year(Date()),1,1)
AND [Prospect Students].[Last Name] In
(SELECT [Last Name]
FROM [Prospect Students] As Tmp
WHERE TMP.[Date of Contact] >=DateSerial(Year(Date()),1,1)
GROUP BY [Last Name], [First Name]
HAVING Count(*)>1
and [First Name] = [Prospect Students].[First Name])
ORDER BY [Prospect Students].[Date of Contact] DESC
, [Prospect Students].[Last Name], [Prospect Students].[First Name];

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

Ricoy-Chicago said:
sorry about the delay... had to grab something to eat...
SQL:
SELECT [Prospect Students].[Date of Contact], [Prospect Students].[Last
Name], [Prospect Students].[First Name], [Prospect Students].SSN,
[Prospect
Students].Address, [Prospect Students].[Lead Source], [Prospect
Students].[Staff Code]
FROM [Prospect Students]
WHERE ((([Prospect Students].[Date of Contact])>#1/1/2007#) AND
(([Prospect
Students].[Last Name]) In (SELECT [Last Name] FROM [Prospect Students] As
Tmp
GROUP BY [Last Name],[First Name] HAVING Count(*)>1 And [First Name] =
[Prospect Students].[First Name])))
ORDER BY [Prospect Students].[Date of Contact] DESC , [Prospect
Students].[Last Name], [Prospect Students].[First Name];

when I run the query, all the records have a 2007 date, there is no
problem
with that but I have records that show only once because a duplicated
record
exist back, let say on September 2006. So i don't want so see those.

Jerry Whittle said:
Show us the SQL. Open the query in design view. Next go to View, SQL
View
and copy and past it here.

Also provide examples of what you do and do not want to see returned by
the
query.
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


:

Access XP. I have created a query to find duplicate records, no problem
here.
Management wants to see duplicated records ONLY for the current
calendar
year. I have a date field and used a criteria to restrict the fields to
the
required dates, no problem here.

Problem: some records show only once because the data may exist in a
previuos year. For example if data was entered in June 2004 and then
the same
data is entered in December 12, 2007 this is NOT considered a
duplicated
record. However, if the data is entered on 1/1/07 and then again today,
this
IS a duplicated record.

This query is used to generate a report, as you can imagine the report
has a
lot of non-duplicated records.

Any help will be greatly appreciated.
 
R

Ricoy-Chicago

I was thinking if you can run a query, saved the results ina table and then
query for duplicated record on that table. This process will give me only the
actual duplicated records. Please my other response.

John Spencer said:
I might try the following. Note that I changed the date comparison to >=
and calculated the date as January 1 of the current year using the
DateSerial function

SELECT [Prospect Students].[Date of Contact]
, [Prospect Students].[Last Name], [Prospect Students].[First Name]
, [Prospect Students].SSN, [Prospect Students].Address
, [Prospect Students].[Lead Source]
, [Prospect Students].[Staff Code]
FROM [Prospect Students]
WHERE [Prospect Students].[Date of Contact]>=DateSerial(Year(Date()),1,1)
AND [Prospect Students].[Last Name] In
(SELECT [Last Name]
FROM [Prospect Students] As Tmp
WHERE TMP.[Date of Contact] >=DateSerial(Year(Date()),1,1)
GROUP BY [Last Name], [First Name]
HAVING Count(*)>1
and [First Name] = [Prospect Students].[First Name])
ORDER BY [Prospect Students].[Date of Contact] DESC
, [Prospect Students].[Last Name], [Prospect Students].[First Name];

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

Ricoy-Chicago said:
sorry about the delay... had to grab something to eat...
SQL:
SELECT [Prospect Students].[Date of Contact], [Prospect Students].[Last
Name], [Prospect Students].[First Name], [Prospect Students].SSN,
[Prospect
Students].Address, [Prospect Students].[Lead Source], [Prospect
Students].[Staff Code]
FROM [Prospect Students]
WHERE ((([Prospect Students].[Date of Contact])>#1/1/2007#) AND
(([Prospect
Students].[Last Name]) In (SELECT [Last Name] FROM [Prospect Students] As
Tmp
GROUP BY [Last Name],[First Name] HAVING Count(*)>1 And [First Name] =
[Prospect Students].[First Name])))
ORDER BY [Prospect Students].[Date of Contact] DESC , [Prospect
Students].[Last Name], [Prospect Students].[First Name];

when I run the query, all the records have a 2007 date, there is no
problem
with that but I have records that show only once because a duplicated
record
exist back, let say on September 2006. So i don't want so see those.

Jerry Whittle said:
Show us the SQL. Open the query in design view. Next go to View, SQL
View
and copy and past it here.

Also provide examples of what you do and do not want to see returned by
the
query.
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


:

Access XP. I have created a query to find duplicate records, no problem
here.
Management wants to see duplicated records ONLY for the current
calendar
year. I have a date field and used a criteria to restrict the fields to
the
required dates, no problem here.

Problem: some records show only once because the data may exist in a
previuos year. For example if data was entered in June 2004 and then
the same
data is entered in December 12, 2007 this is NOT considered a
duplicated
record. However, if the data is entered on 1/1/07 and then again today,
this
IS a duplicated record.

This query is used to generate a report, as you can imagine the report
has a
lot of non-duplicated records.

Any help will be greatly appreciated.
 
J

John Spencer

Did you try the query I posted? Did it fail to give you the desired
results? Or did it generate an error?

I believe that it should return the records you are interested in.

Alternate Two query approach.
Build a query to select all the records for the time frame you are
interested in. Now use the duplicates query against that query.

SELECT [Prospect Students].[Date of Contact]
, [Prospect Students].[Last Name], [Prospect Students].[First Name]
, [Prospect Students].SSN, [Prospect Students].Address
, [Prospect Students].[Lead Source]
, [Prospect Students].[Staff Code]
FROM [Prospect Students]
WHERE [Prospect Students].[Date of Contact]>=#1/1/2007#
Save the above as qCurProspect

Now use the duplicates query wizard to build a query returning the
duplicates in the above query

SELECT *
FROM QCurProspects
WHERE [Last Name] IN (
SELECT [Last Name]
FROM QCurProspects As Tmp
GROUP BY [Last Name], [First Name]
HAVING Count(*)>1
and [First Name] = [QCurProspects].[First Name])
ORDER BY [Last Name], [First Name]

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

Ricoy-Chicago said:
Jerry's and Karl's SQL statement did not work. Thank you to both but
Karl's
is closer to what I want but still is not the correct output. I am going
to
try an example:

Case A. Joe Doe's information is entered on 9/9/05 and then it is
re-entered
on 7/7/07. This is not a duplicated record on 2007.

Case B. Joe Doe's infromation is entered on 2/2/07 and then it is
re-entered
on 10/31/07. This is a duplicated record for 2007.

For case B there is no problem.

For case A, the query should not show Joe Doe' records; however, the query
shows Joe doe once, because his data was entered on 9/9/05 (previous
calndar
year) it is not a duplicated record in 2007. He should not appear at all.
That's what my problem is, I end with a lot of "single" records.

John Spencer said:
I might try the following. Note that I changed the date comparison to >=
and calculated the date as January 1 of the current year using the
DateSerial function

SELECT [Prospect Students].[Date of Contact]
, [Prospect Students].[Last Name], [Prospect Students].[First Name]
, [Prospect Students].SSN, [Prospect Students].Address
, [Prospect Students].[Lead Source]
, [Prospect Students].[Staff Code]
FROM [Prospect Students]
WHERE [Prospect Students].[Date of Contact]>=DateSerial(Year(Date()),1,1)
AND [Prospect Students].[Last Name] In
(SELECT [Last Name]
FROM [Prospect Students] As Tmp
WHERE TMP.[Date of Contact] >=DateSerial(Year(Date()),1,1)
GROUP BY [Last Name], [First Name]
HAVING Count(*)>1
and [First Name] = [Prospect Students].[First Name])
ORDER BY [Prospect Students].[Date of Contact] DESC
, [Prospect Students].[Last Name], [Prospect Students].[First Name];

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

Ricoy-Chicago said:
sorry about the delay... had to grab something to eat...
SQL:
SELECT [Prospect Students].[Date of Contact], [Prospect Students].[Last
Name], [Prospect Students].[First Name], [Prospect Students].SSN,
[Prospect
Students].Address, [Prospect Students].[Lead Source], [Prospect
Students].[Staff Code]
FROM [Prospect Students]
WHERE ((([Prospect Students].[Date of Contact])>#1/1/2007#) AND
(([Prospect
Students].[Last Name]) In (SELECT [Last Name] FROM [Prospect Students]
As
Tmp
GROUP BY [Last Name],[First Name] HAVING Count(*)>1 And [First Name] =
[Prospect Students].[First Name])))
ORDER BY [Prospect Students].[Date of Contact] DESC , [Prospect
Students].[Last Name], [Prospect Students].[First Name];

when I run the query, all the records have a 2007 date, there is no
problem
with that but I have records that show only once because a duplicated
record
exist back, let say on September 2006. So i don't want so see those.

:

Show us the SQL. Open the query in design view. Next go to View, SQL
View
and copy and past it here.

Also provide examples of what you do and do not want to see returned
by
the
query.
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


:

Access XP. I have created a query to find duplicate records, no
problem
here.
Management wants to see duplicated records ONLY for the current
calendar
year. I have a date field and used a criteria to restrict the fields
to
the
required dates, no problem here.

Problem: some records show only once because the data may exist in a
previuos year. For example if data was entered in June 2004 and then
the same
data is entered in December 12, 2007 this is NOT considered a
duplicated
record. However, if the data is entered on 1/1/07 and then again
today,
this
IS a duplicated record.

This query is used to generate a report, as you can imagine the
report
has a
lot of non-duplicated records.

Any help will be greatly appreciated.
 
R

Ricoy-Chicago

I tried the queries posted by Jerry and Karl. Jerry's run did not run at
first but just like Karl's, they ended showing "single" records as I
explained already.

Your comments are exactly what I wnat to try, create a query that gives all
the duplicated records including "singles" and requery to end up with the
actual diplicated ones.

I will try your query and let yopu knwo what happened... Thanks

John Spencer said:
Did you try the query I posted? Did it fail to give you the desired
results? Or did it generate an error?

I believe that it should return the records you are interested in.

Alternate Two query approach.
Build a query to select all the records for the time frame you are
interested in. Now use the duplicates query against that query.

SELECT [Prospect Students].[Date of Contact]
, [Prospect Students].[Last Name], [Prospect Students].[First Name]
, [Prospect Students].SSN, [Prospect Students].Address
, [Prospect Students].[Lead Source]
, [Prospect Students].[Staff Code]
FROM [Prospect Students]
WHERE [Prospect Students].[Date of Contact]>=#1/1/2007#
Save the above as qCurProspect

Now use the duplicates query wizard to build a query returning the
duplicates in the above query

SELECT *
FROM QCurProspects
WHERE [Last Name] IN (
SELECT [Last Name]
FROM QCurProspects As Tmp
GROUP BY [Last Name], [First Name]
HAVING Count(*)>1
and [First Name] = [QCurProspects].[First Name])
ORDER BY [Last Name], [First Name]

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

Ricoy-Chicago said:
Jerry's and Karl's SQL statement did not work. Thank you to both but
Karl's
is closer to what I want but still is not the correct output. I am going
to
try an example:

Case A. Joe Doe's information is entered on 9/9/05 and then it is
re-entered
on 7/7/07. This is not a duplicated record on 2007.

Case B. Joe Doe's infromation is entered on 2/2/07 and then it is
re-entered
on 10/31/07. This is a duplicated record for 2007.

For case B there is no problem.

For case A, the query should not show Joe Doe' records; however, the query
shows Joe doe once, because his data was entered on 9/9/05 (previous
calndar
year) it is not a duplicated record in 2007. He should not appear at all.
That's what my problem is, I end with a lot of "single" records.

John Spencer said:
I might try the following. Note that I changed the date comparison to >=
and calculated the date as January 1 of the current year using the
DateSerial function

SELECT [Prospect Students].[Date of Contact]
, [Prospect Students].[Last Name], [Prospect Students].[First Name]
, [Prospect Students].SSN, [Prospect Students].Address
, [Prospect Students].[Lead Source]
, [Prospect Students].[Staff Code]
FROM [Prospect Students]
WHERE [Prospect Students].[Date of Contact]>=DateSerial(Year(Date()),1,1)
AND [Prospect Students].[Last Name] In
(SELECT [Last Name]
FROM [Prospect Students] As Tmp
WHERE TMP.[Date of Contact] >=DateSerial(Year(Date()),1,1)
GROUP BY [Last Name], [First Name]
HAVING Count(*)>1
and [First Name] = [Prospect Students].[First Name])
ORDER BY [Prospect Students].[Date of Contact] DESC
, [Prospect Students].[Last Name], [Prospect Students].[First Name];

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

sorry about the delay... had to grab something to eat...
SQL:
SELECT [Prospect Students].[Date of Contact], [Prospect Students].[Last
Name], [Prospect Students].[First Name], [Prospect Students].SSN,
[Prospect
Students].Address, [Prospect Students].[Lead Source], [Prospect
Students].[Staff Code]
FROM [Prospect Students]
WHERE ((([Prospect Students].[Date of Contact])>#1/1/2007#) AND
(([Prospect
Students].[Last Name]) In (SELECT [Last Name] FROM [Prospect Students]
As
Tmp
GROUP BY [Last Name],[First Name] HAVING Count(*)>1 And [First Name] =
[Prospect Students].[First Name])))
ORDER BY [Prospect Students].[Date of Contact] DESC , [Prospect
Students].[Last Name], [Prospect Students].[First Name];

when I run the query, all the records have a 2007 date, there is no
problem
with that but I have records that show only once because a duplicated
record
exist back, let say on September 2006. So i don't want so see those.

:

Show us the SQL. Open the query in design view. Next go to View, SQL
View
and copy and past it here.

Also provide examples of what you do and do not want to see returned
by
the
query.
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


:

Access XP. I have created a query to find duplicate records, no
problem
here.
Management wants to see duplicated records ONLY for the current
calendar
year. I have a date field and used a criteria to restrict the fields
to
the
required dates, no problem here.

Problem: some records show only once because the data may exist in a
previuos year. For example if data was entered in June 2004 and then
the same
data is entered in December 12, 2007 this is NOT considered a
duplicated
record. However, if the data is entered on 1/1/07 and then again
today,
this
IS a duplicated record.

This query is used to generate a report, as you can imagine the
report
has a
lot of non-duplicated records.

Any help will be greatly appreciated.
 
R

Ricoy-Chicago

Yes! it did work !-) The first query gave me 246 records, the second query,
based on the first gave only 34! and only those that were entered twice.

Thanks you very much for your help.

John Spencer said:
Did you try the query I posted? Did it fail to give you the desired
results? Or did it generate an error?

I believe that it should return the records you are interested in.

Alternate Two query approach.
Build a query to select all the records for the time frame you are
interested in. Now use the duplicates query against that query.

SELECT [Prospect Students].[Date of Contact]
, [Prospect Students].[Last Name], [Prospect Students].[First Name]
, [Prospect Students].SSN, [Prospect Students].Address
, [Prospect Students].[Lead Source]
, [Prospect Students].[Staff Code]
FROM [Prospect Students]
WHERE [Prospect Students].[Date of Contact]>=#1/1/2007#
Save the above as qCurProspect

Now use the duplicates query wizard to build a query returning the
duplicates in the above query

SELECT *
FROM QCurProspects
WHERE [Last Name] IN (
SELECT [Last Name]
FROM QCurProspects As Tmp
GROUP BY [Last Name], [First Name]
HAVING Count(*)>1
and [First Name] = [QCurProspects].[First Name])
ORDER BY [Last Name], [First Name]

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

Ricoy-Chicago said:
Jerry's and Karl's SQL statement did not work. Thank you to both but
Karl's
is closer to what I want but still is not the correct output. I am going
to
try an example:

Case A. Joe Doe's information is entered on 9/9/05 and then it is
re-entered
on 7/7/07. This is not a duplicated record on 2007.

Case B. Joe Doe's infromation is entered on 2/2/07 and then it is
re-entered
on 10/31/07. This is a duplicated record for 2007.

For case B there is no problem.

For case A, the query should not show Joe Doe' records; however, the query
shows Joe doe once, because his data was entered on 9/9/05 (previous
calndar
year) it is not a duplicated record in 2007. He should not appear at all.
That's what my problem is, I end with a lot of "single" records.

John Spencer said:
I might try the following. Note that I changed the date comparison to >=
and calculated the date as January 1 of the current year using the
DateSerial function

SELECT [Prospect Students].[Date of Contact]
, [Prospect Students].[Last Name], [Prospect Students].[First Name]
, [Prospect Students].SSN, [Prospect Students].Address
, [Prospect Students].[Lead Source]
, [Prospect Students].[Staff Code]
FROM [Prospect Students]
WHERE [Prospect Students].[Date of Contact]>=DateSerial(Year(Date()),1,1)
AND [Prospect Students].[Last Name] In
(SELECT [Last Name]
FROM [Prospect Students] As Tmp
WHERE TMP.[Date of Contact] >=DateSerial(Year(Date()),1,1)
GROUP BY [Last Name], [First Name]
HAVING Count(*)>1
and [First Name] = [Prospect Students].[First Name])
ORDER BY [Prospect Students].[Date of Contact] DESC
, [Prospect Students].[Last Name], [Prospect Students].[First Name];

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

sorry about the delay... had to grab something to eat...
SQL:
SELECT [Prospect Students].[Date of Contact], [Prospect Students].[Last
Name], [Prospect Students].[First Name], [Prospect Students].SSN,
[Prospect
Students].Address, [Prospect Students].[Lead Source], [Prospect
Students].[Staff Code]
FROM [Prospect Students]
WHERE ((([Prospect Students].[Date of Contact])>#1/1/2007#) AND
(([Prospect
Students].[Last Name]) In (SELECT [Last Name] FROM [Prospect Students]
As
Tmp
GROUP BY [Last Name],[First Name] HAVING Count(*)>1 And [First Name] =
[Prospect Students].[First Name])))
ORDER BY [Prospect Students].[Date of Contact] DESC , [Prospect
Students].[Last Name], [Prospect Students].[First Name];

when I run the query, all the records have a 2007 date, there is no
problem
with that but I have records that show only once because a duplicated
record
exist back, let say on September 2006. So i don't want so see those.

:

Show us the SQL. Open the query in design view. Next go to View, SQL
View
and copy and past it here.

Also provide examples of what you do and do not want to see returned
by
the
query.
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


:

Access XP. I have created a query to find duplicate records, no
problem
here.
Management wants to see duplicated records ONLY for the current
calendar
year. I have a date field and used a criteria to restrict the fields
to
the
required dates, no problem here.

Problem: some records show only once because the data may exist in a
previuos year. For example if data was entered in June 2004 and then
the same
data is entered in December 12, 2007 this is NOT considered a
duplicated
record. However, if the data is entered on 1/1/07 and then again
today,
this
IS a duplicated record.

This query is used to generate a report, as you can imagine the
report
has a
lot of non-duplicated records.

Any help will be greatly appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top