B
barbapapa
I have a table that contains: CustomerName, Add Nm1, Add Nm2, Add Ln1, Add
Ln2, City, Zip. The same customer can be in the table with a different
address or with the same address and I want to find the ones with the same
address (the duplicates), I cannot use the find duplicates wizard because
it's only based on one field.
So I try using recordset, I made 2 recordsets of my table and want to
compare the first record from my first recordset (rs1) against all the
record in my second recordset (rs2) if no match move to the next record in
rs1 and start all over again if find match then copy record to a third
table. When I run the program in the first pass it found no match, in the
second pass it tells me there is a match between the second customer in rs1
and the third customer in rs2 (but that's not true) then it leaves the inner
loop execute the outer loop then go back to the inner loop and tells me
there is a match between the 3rd customer in rs1 and the 4th customer in
rs2, then it keep doing that. what am I doing wrong? Hope that makes
sense. Thanks.
rs1.MoveFirst
rs2.MoveFirst
rs2.MoveNext
Do Until rs1.EOF
Do Until rs2.EOF
If rs1(1).Value = rs2(1).Value And rs1(2) = rs2(2) And
rs1(3) = rs2(3) And rs1(4) = rs2(4)
And rs1(5) = rs2(5) And rs1(6) = rs2(6) And rs1(7) =
rs2(7) Then
'move the record from rs1 to a third table. Have not
work on that part yet
rs2.MoveNext
Else
rs2.MoveNext
End If
Loop
rs1.MoveNext
rs2.MoveFirst
Loop
Ln2, City, Zip. The same customer can be in the table with a different
address or with the same address and I want to find the ones with the same
address (the duplicates), I cannot use the find duplicates wizard because
it's only based on one field.
So I try using recordset, I made 2 recordsets of my table and want to
compare the first record from my first recordset (rs1) against all the
record in my second recordset (rs2) if no match move to the next record in
rs1 and start all over again if find match then copy record to a third
table. When I run the program in the first pass it found no match, in the
second pass it tells me there is a match between the second customer in rs1
and the third customer in rs2 (but that's not true) then it leaves the inner
loop execute the outer loop then go back to the inner loop and tells me
there is a match between the 3rd customer in rs1 and the 4th customer in
rs2, then it keep doing that. what am I doing wrong? Hope that makes
sense. Thanks.
rs1.MoveFirst
rs2.MoveFirst
rs2.MoveNext
Do Until rs1.EOF
Do Until rs2.EOF
If rs1(1).Value = rs2(1).Value And rs1(2) = rs2(2) And
rs1(3) = rs2(3) And rs1(4) = rs2(4)
And rs1(5) = rs2(5) And rs1(6) = rs2(6) And rs1(7) =
rs2(7) Then
'move the record from rs1 to a third table. Have not
work on that part yet
rs2.MoveNext
Else
rs2.MoveNext
End If
Loop
rs1.MoveNext
rs2.MoveFirst
Loop