ADO find method

Z

zz

I've coded a somewhat complex conversion program. Its creating a table based
on the contents of another table. I'm creating an artificial key composed of
name and phone number that must be unique.
Before I add records to the target recordset I need to issue a find command
on the previoulsy added records to see if it is a duplicate. Sometimes this
works and sometimes it does not. I think it may be failing only when the
immediately preceding record is the duplicate. Here is the skeleton of my
code, any ideas?

While Not rs1.EOF
' Form artificial key
strCID = strULN & Left$(strUFN, 1) & Right$(strTel, 4)
' Check if already exists
If Not rs2.BOF Then
rs2.Find "ClientCode = '" & Replace(strCID, "'", "''") & "'", ,
adSearchBackward
End If
If rs2.BOF Then
If Not rs2.EOF Then
rs2.MoveLast
End If
rs2.AddNew
......
rs2.Update
Else
rs2.MoveLast
End If
rs1.MoveNext
Wend
 

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

Similar Threads

DAO - apostrophe in primary key 4
Recordset Code Help 12
stuck in a loop 5
Append Recordset 2
On Change Update Subform 1
query on query 1
Run time error in VBA Code 1
Data Type Conversion error 5

Top