Hello,

I am using ADODB to create new record in an access db. Now, that I'm past that hurdle, how do I check if the unique key already exists and then update that record? Any help would be greatly appreciated.

Private Sub CommandButton1_Click()
' exports data from the active worksheet to a table in an Access database
' this procedure must be edited before use
'Dim db As ADODB.Database, rs As DAO.Recordset, r As Long
Dim r As Long
Dim db As ADODB.Connection
Dim rs As ADODB.Recordset

Set db = New ADODB.Connection
db.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source =" & _
"C:\InspectionDB.accdb;"


    db.Open
    Set rs = New ADODB.Recordset
    
    rs.Open "FinalInspection", db, adOpenDynamic, adLockOptimistic
    r = 2 ' the start row in the worksheet
  
            rs.AddNew ' create a new record
            ' add values to each field in the record
            rs.Fields("Job Number") = Range("A" & r).Value  ' Unique Key
            rs.Fields("Inspection Date") = Range("B" & r).Value
            rs.Fields("SHIP DATE") = Range("C" & r).Value
            
    rs.Close
    Set rs = Nothing
    db.Close

End Sub