Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access 97 question 3

Status
Not open for further replies.

tdpman

Technical User
Apr 29, 2002
44
US
I have a Access table that contains many duplicate records. One of the fields within this table is a date field. I am needing some code (or something) that will delete all the duplicate records except the one with the earliest date. Any ideas? THX!

Examples:

SO NUMBER LOA LOC SO VERSION LOA OUTPUT CODE DATE LOA SENT
1959066 WNCH.CPT 99 F 1/7/02
1959066 WNCH.CPT 98 F 1/7/02
1959066 WNCH.CPT 99 F 1/7/02
1959066 WNCH.CPT 98 F 1/7/02
1959066 WNCH.CPT 98 F 1/7/02
1959066 WNCH.CPT 99 F 1/7/02
1959066 WNCH.CPT 99 F 1/10/02
1959066 MGTW.CPT 98 F 1/10/02
 
Thanks cmmrfrds for the correct sql statement, i'm not sure why i went of on such a tangent....

Cheers,
Dan
 
OK, the code worked for me. Took a while to run, but it eventually worked. Thanks a bunch!!!

One last question, how can I modify the code to where it doesn't pull over any records where there is not a date in the "DATE LOA SENT" field? Not a big deal, I can work around it if it's too big of a deal.

tp
 
You should be able to mdify the following line:

If rsTable.Fields(&quot;DATE LOA SENT&quot;) <> .Fields(&quot;MinOfDATE LOA SENT&quot;) Then

to:

If rsTable.Fields(&quot;DATE LOA SENT&quot;) <> .Fields(&quot;MinOfDATE LOA SENT&quot;) Or IsNull(rsTable.Fields(&quot;DATE LOA SENT&quot;)) Then

to get what you want.....
Please remember to give helpful posts the stars they deserve!
This makes the post more visible to others in need! [thumbsup2]

Robert L. Johnson III, A+, Network+, MCP
Access Developer/Programmer
robert.l.johnson.iii@citigroup.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top