I have a form where the field, [txtTicker] would be the primary method of searching within my form as well as editing a record (not to be confused with primary key). I've tried using the DLookup function to take the entered field in my form, txtTicker, and compare it to my table, [Companytable] with the respective field, [Ticker], but my syntax and design are probably both incorrect. I'm placing the code in my form within a sub procedure that is taking all my data entered and inserting it into my table. I'd like to prompt myself prior to executing the SQL code that the primary entry txtTicker already exists and if so do I wish to overwrite the data or cancel the action. It's possible I should be writing a query or two to perform these steps but I'm getting bogged down a bit. Any suggestions would be most helpful.
'prevent dupes by checking my table and alert
If IsNull(DLookup("[Ticker]", _
"[Companytable]", _
"[Ticker]='" & Me.txtTicker & "'")) Then
MsgBox "Duplicate!"
End If
So, this is returning "Duplicate" only when it's an original. Not what i'm looking for naturally. I tried using NotIsNull but that had errors. Thanks in advance!