If field1 is set as the PRIMARY KEY or a UNIQUE column, then it will not accept duplicate values. Personally I think it is best practice to test for duplicates before attempting an insert, so that you can nicely control the action. This is easily done with a small select:
cmd.CommandText = "SELECT ROWID from My_table WHERE Name = '" & txtName.Text & "'"
reader.Value = cmd.ExecuteReader
havedup = reader.ReadNextRow
reader.Close
If havedup Then
Msgbox(txtName.Text & " already exists!" & crlf & "Must be unique.",,cMsgBoxHand)
Return
End If
Geoff.
|