M
mscertified
I'm using DAO to process a recordset, I build SQL using
replace(MyName,"'","''") because primary key contains names which may have
apostrophes.
I do a FINDFIRST looking for the key, I get a NOMATCH on the record even
though it is there and then my add fails with duplicate index.
How should this be handled?
Here is my code:
strFN = rs1.Fields("FirstName").Value
strLN = rs1.Fields("LastName").Value
strTel = rs1.Fields("PubPhoneNumber").Value
strCC = strLN & Left$(strFN, 1) & Right$(strTel, 4)
strSQL = "ClientCode = '" & Replace(strCC, "'", "''") & "'"
rs2.FindFirst strSQL
If rs2.NoMatch Then
' Add new record
With rs2
.AddNew
.Fields("ClientCode").Value = strCC
............
.Update <========= fails with dup key
End With
Else
replace(MyName,"'","''") because primary key contains names which may have
apostrophes.
I do a FINDFIRST looking for the key, I get a NOMATCH on the record even
though it is there and then my add fails with duplicate index.
How should this be handled?
Here is my code:
strFN = rs1.Fields("FirstName").Value
strLN = rs1.Fields("LastName").Value
strTel = rs1.Fields("PubPhoneNumber").Value
strCC = strLN & Left$(strFN, 1) & Right$(strTel, 4)
strSQL = "ClientCode = '" & Replace(strCC, "'", "''") & "'"
rs2.FindFirst strSQL
If rs2.NoMatch Then
' Add new record
With rs2
.AddNew
.Fields("ClientCode").Value = strCC
............
.Update <========= fails with dup key
End With
Else