Hi all, I have this sub that should add new record to the MS Access database Which I have the following fields: url (Primary key), page, indexed

If the url was found there then just update the record, else add a new record with the new url you have.

This is my code, BUT this still giving me (Duplicate error) when entering a url that is in the database.

Code:
Private Sub cmd_save_Click()
    Dim sql As String
    sql = "SELECT url FROM Table1 WHERE url LIKE '%" & wb1.LocationURL & "&'"
    Set dbrs = New ADODB.Recordset
    dbrs.Open sql, dbconn, adOpenKeyset, adLockPessimistic, adCmdText
    
    If dbrs.EOF Then
        Set dbrs2 = New ADODB.Recordset
        dbrs2.Open "Table1", dbconn, adOpenKeyset, adLockPessimistic, adCmdTable
        With dbrs2
            .AddNew
            .Fields("url") = wb1.LocationURL
            .Fields("page") = txt_page.Text
            .Fields("indexed") = Now()
            .Update
        End With
    Else
        Set dbrs2 = New ADODB.Recordset
        dbrs2.Open "Table1", dbconn, adOpenKeyset, adLockPessimistic, adCmdTable
        With dbrs2
            .Fields("url") = wb1.LocationURL
            .Fields("page") = txt_page.Text
            .Fields("indexed") = Now()
            .Update
        End With
    End If

    MsgBox "MAIN PAGE HAS BEEN ADDED"
End Sub
I need someone to fix it for me,
Thanks very much,
zeid