Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

remove duplicates acess 2000

Posted on 2005-03-22
3
Medium Priority
?
146 Views
Last Modified: 2006-11-17
here i go.I have this table that i want to check for duplicate entries,the name,tblled,the fields with the duplicate entries are,dsdate,time,seq,deviceno, when the duplicates are found i would like to remove one of the entries to a table (tbldups) to be verified before i actually delete.I would like to attached the code to a cmdbutton,or if possilble have this done at the first of every month before i actually run reports.
thanks
0
Comment
Question by:wwstudioinc
3 Comments
 
LVL 3

Expert Comment

by:poaysee
ID: 13599969
Step 1:
you go to query, click on the new -> choose the "Find duplicates Query view" -> Choose the table or the query name you want to find the duplicate -> put in the field name which you want to check within those fields name -> save as a new query.
Step 2:
You link the original table/Query with the duplicate data, and check on the data
Step 3:
DoCmd.RunSQL "Delete From tableName where ... (condition)"
0
 
LVL 9

Expert Comment

by:solution46
ID: 13600107
qry 1 (qry_tblled_dups)...
SELECT Max([your_id_field]) row_id
FROM tblled
GROUP BY dsdate, [time], seq, deviceno
HAVING Count([your_id_field]) > 1

qry 2 (qry_tblled_listdups)...
INSERT INTO tbldups
SELECT *
FROM tblled
    INNER JOIN qry_tblled_dups
        ON tblled.[your_id_field] = qry_tblled_dups.row_id

qry 3 (qry_tblled_deldups)
DELETE FROM tblled
WHERE [your_id_field] IN (SELECT row_id FROM tbldups)

qry 4 (qry_tbldups_truncate)
DELETE FROM tbldups


Process...
1. run qry_tbldups_truncate
2. run qry_tblled_listdups
3. look through data in tbldups using a form or whatever. Delete any rows you want to leave in tblled.
4. run qry_tblled_deldups
5. run qry_tbldups_truncate


Notes...
1. This will only work if you have a unique id field ([your_id_field]) in the table tblled, or a group of fields that together form a unique id. Without this you have no way of isolating a single row and you wont be able to use a query or any other automated process to get rid of your duplicates.
2. tbldups must have exactly the same structure as tblled, and should ideally have [your_id_field] indexed.
3. All this is air code so check it for typos, etc., don't be surprised if there's a bug (if the cause isn't obvious, post it up here and I'll take a look) and back up your database before trying this!

Hope this helps,

s46
0
 
LVL 38

Accepted Solution

by:
puppydogbuddy earned 1500 total points
ID: 13600291
The link below gives you a tried and true step by step how to do it.
                      http://www.fabalou.com/Access/Queries/delete_dupe_records.asp
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question