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

**URL:** <https://clarionhub.com/t/fixing-duplicate-error-adding-this-record-creates-a-duplicate-entry-for-the-key/6550>\
**Category:** questions\
**Tags:** errorcodes, dictionary\
**Created:** [August 31, 2023, 10:37am UTC](https://clarionhub.com/t/fixing-duplicate-error-adding-this-record-creates-a-duplicate-entry-for-the-key/6550 "2023-08-31T10:37:05Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![StaceyRobinson](https://clarionhub.com/letter_avatar_proxy/v4/letter/s/958977/32.png) [@StaceyRobinson](https://clarionhub.com/u/StaceyRobinson)\
**Post date:** [August 31, 2023, 10:37am UTC](https://clarionhub.com/t/fixing-duplicate-error-adding-this-record-creates-a-duplicate-entry-for-the-key/6550/1 "2023-08-31T10:37:05Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![donridley](https://clarionhub.com/user_avatar/clarionhub.com/donridley/32/1459_2.png) [@donridley](https://clarionhub.com/u/donridley)\
**Post date:** [August 31, 2023, 11:12am UTC](https://clarionhub.com/t/fixing-duplicate-error-adding-this-record-creates-a-duplicate-entry-for-the-key/6550/2 "2023-08-31T11:12:56Z")

</div>

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 [www.capesoft.com](http://www.capesoft.com) 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.

---

<div class="post-metadata">

**Author:** ![StaceyRobinson](https://clarionhub.com/letter_avatar_proxy/v4/letter/s/958977/32.png) [@StaceyRobinson](https://clarionhub.com/u/StaceyRobinson)\
**Post date:** [August 31, 2023, 11:18am UTC](https://clarionhub.com/t/fixing-duplicate-error-adding-this-record-creates-a-duplicate-entry-for-the-key/6550/3 "2023-08-31T11:18:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jslarve](https://clarionhub.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@jslarve](https://clarionhub.com/u/jslarve)\
**Post date:** [August 31, 2023, 12:43pm UTC](https://clarionhub.com/t/fixing-duplicate-error-adding-this-record-creates-a-duplicate-entry-for-the-key/6550/4 "2023-08-31T12:43:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![CarlBarnes](https://clarionhub.com/user_avatar/clarionhub.com/carlbarnes/32/1859_2.png) [@CarlBarnes](https://clarionhub.com/u/CarlBarnes)\
**Post date:** [August 31, 2023, 3:35pm UTC](https://clarionhub.com/t/fixing-duplicate-error-adding-this-record-creates-a-duplicate-entry-for-the-key/6550/5 "2023-08-31T15:35:01Z")

</div>

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():

```auto
!OF ?Ok - Before Generated Code Embed
IF DUPLICATE(Emp:KeySSN) THEN 
   SELECT(?Emp:SSN)
   !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')
   CYCLE
END 

```

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

```auto
IF DUPLICATE(Pre:BOKeyGUID) THEN 
   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 
      CYCLE
   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)       
      CYCLE
   END 
END 

```

---

<div class="post-metadata">

**Author:** ![Bruce](https://clarionhub.com/letter_avatar_proxy/v4/letter/b/ccd318/32.png) [@Bruce](https://clarionhub.com/u/Bruce)\
**Post date:** [August 31, 2023, 7:44pm UTC](https://clarionhub.com/t/fixing-duplicate-error-adding-this-record-creates-a-duplicate-entry-for-the-key/6550/6 "2023-08-31T19:44:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![StaceyRobinson](https://clarionhub.com/letter_avatar_proxy/v4/letter/s/958977/32.png) [@StaceyRobinson](https://clarionhub.com/u/StaceyRobinson)\
**Post date:** [September 1, 2023, 10:11am UTC](https://clarionhub.com/t/fixing-duplicate-error-adding-this-record-creates-a-duplicate-entry-for-the-key/6550/7 "2023-09-01T10:11:26Z")

</div>

Nope, none of the keys have autonumber on them.

---

<div class="post-metadata">

**Author:** ![Clarion\_clarion](https://clarionhub.com/user_avatar/clarionhub.com/clarion_clarion/32/636_2.png) [@Clarion\_clarion](https://clarionhub.com/u/Clarion_clarion)\
**Post date:** [September 1, 2023, 10:59am UTC](https://clarionhub.com/t/fixing-duplicate-error-adding-this-record-creates-a-duplicate-entry-for-the-key/6550/8 "2023-09-01T10:59:25Z")

</div>

could you please post here your table definition?

---

<div class="post-metadata">

**Author:** ![StaceyRobinson](https://clarionhub.com/letter_avatar_proxy/v4/letter/s/958977/32.png) [@StaceyRobinson](https://clarionhub.com/u/StaceyRobinson)\
**Post date:** [September 1, 2023, 2:31pm UTC](https://clarionhub.com/t/fixing-duplicate-error-adding-this-record-creates-a-duplicate-entry-for-the-key/6550/9 "2023-09-01T14:31:09Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![CarlBarnes](https://clarionhub.com/user_avatar/clarionhub.com/carlbarnes/32/1859_2.png) [@CarlBarnes](https://clarionhub.com/u/CarlBarnes)\
**Post date:** [September 1, 2023, 6:55pm UTC](https://clarionhub.com/t/fixing-duplicate-error-adding-this-record-creates-a-duplicate-entry-for-the-key/6550/10 "2023-09-01T18:55:59Z")

</div>

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.

 ![image](https://clarionhub-uploads.s3.eu-north-1.amazonaws.com/original/2X/2/2cfbcb3c09b18501e34b6e599039deed56da2af5.png)
