Table Duplicate Records

G

Guest

Hi, I hope all is well with you.

I have a table with duplicate entries and need to sort thru the table to
remove the duplicates. Not all records are duplicate, just some. If I create
module to check record 1 against the remaining record, how do I keep from
checking record 1 against itself? For example and as I see it, I would have
two DO loops. First to sift thru each record in the table and the second to
compare the remaining records in the table with data in record 1. If a match,
I'd Y/N mark a field in the record to indicate the record is a duplicate but
would not mark the record in the first DO loop. Two questions:

1) If I am on record 12 in first DO loop, how do I keep the second DO loop
from comparing the data in record 12 with itself? IOW, is there a way to
check the current record being evaluated to prevent comparing it to itself?
2) Is there an easier way to do this, and if so what is it?

Thanks for any help and have a great day/weekend.

KP
 
G

Guest

Try this approach. Create a temporary table that looks like your permenant
table.
Then (air psuedo untested sorta like code)

set rstPerm = open the perm table

rstperm.movelast
rstperm.movefirst

do while not rstperm.eof
if isnull(dlookup([some_field],"tbltemp","some dup thing")) then
currentdb.execute "INSERT * INTO tbltemp....blah, blah, blah VALUES
endif
rstperm.movenext
loop
rstperm.close
currentdb.execute "DELETE * FROM tblperm"
currentdb.executer "INSERT * INTO tblperm SELECT * FROM tbltem

Clean up the syntax, and go for it
Note that the DLookup is where it checks for dups. If it returns other than
Null, the record that meets the criteria is already there.
 

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