Can you please explain what you mean when you says "it is strucking" on the Update statement? Is it producing an error? If so, what error?
If the problem is that you're attempting to create a duplicate record, then it may be because you're only comparing your text (
copnme_txt.Text) to the current record. What about all the other records?
I'd suggest considering one of the following approaches:
- Check for a duplicate by using a Find - you might want to put this in a Function to keep your code simple. So you can say for example
-
If RecordAlreadyExists(copnme_txt.Text) Then
-
reset
-
Else
-
rs2.AddNew
-
rs2.Fields(0) = copnme_txt.Text
-
rs2.Update
-
reset
-
End If
-
- Use error-handling to trap the "duplicate record" error. For example...
-
On Error Resume Next ' Turn on error trapping
-
rs2.AddNew
-
rs2.Fields(0) = copnme_txt.Text
-
rs2.Update
-
If Error.Number <> [I forget the number] Then
-
Debug.Print Error.Description
-
End If
-
On Error Goto Next ' Turn off error trapping
-
reset
-