Fixing Duplicate Error: Adding this record creates a duplicate entry for the key

I’ll be asking quite a few newbie questions in the next few days so bear with me.

I’m getting the error “Adding this record creates a duplicate entry for the key: BOKeyGUID”.

Could someone please explain what this means?

The Key is set as unique in the dictionary. So that error is telling you that you are attempting to add a record with a key value that already exists. That includes a blank key value. Double check that the key value is being populated.

There’s a product from called StringTheory that has become pretty much a must have nowadays. It has has a method called MakeGuid that can create random GUID’s just for this purpose.

Thanks for the response!

I am using the StringTheory extension, and the record is operating on a GUID. I have 1 record containing a name and 2 other fields, but the error appears when I try to add another record in the same browse box, even if the names are different.

Check your data table to see if there are any records where the column in question is blank. Perhaps your program is trying to add another blank one. If that is the case, maybe you need to modify the program to prime the record before insertion in such a way that this doesn’t happen.

1 Like

To make it better for the end user to understand in your OK Button “Accepted Event - BEFORE Generated Code” check IF Dup and add your own better Message():

!OF ?Ok  -  Before Generated Code Embed
   !I would use an Alias file to look up the Dup record so the message can tell them 
   MESSAGE('A Person already exists with the same SSN','Duplicate SSN')

Well … it appears your duplicate is on a Key that is a GUID that would not be a user entry so maybe.

   IF OriginalRequest = InsertRecord THEN 
      MESSAGE('An unexpected duplicate occurred on an internal unique ID. '& |
              '||A new ID will be generated. Please contact tech support if this persists.','Duplicate ID')
      Pre:GUID = GetNewGUID() ; DISPLAY 
   ELSIF OriginalRequest = ChangeRecord THEN  !Should Never Happen 
      MESSAGE('An unexpected duplicate occurred on an internal unique ID.' & |
              '||This ID cannot be changed. Please contact tech support.','Duplicate ID', Icon:Hand)       

Does the table have an Auto Numbered Key on either the Guud key, or another key?

Nope, none of the keys have autonumber on them.

could you please post here your table definition?

Just an update for all who’ve been kind enough to help: this project was absolutely riddled with holes in the dictionary so I reworked the dct to add the right relationships and the right keys, I also had to add the MakeGUID manually on some GUID columns on the Field Priming on Insert. That’s all I can find right now that was screwing me up. Thank you for all your help!

I’ll mention a potential gotcha … when doing a ADD() the DUPLICATE() function can return a False Positive if you failed to do a GET(File, 0) to clear the record pointer.

The standard template code does the GET(,0) but often some added hand code will omit that. IIRC the Legacy Form Template (Save Button) set to “Insert another record” does not have a GET(,0), I fixed it in mine when I ran into this error. This lack of a GET(,0) does Not cause the ADD() to error.