# Stop Duplicate Entry

**URL:** <https://community.thunkable.com/t/stop-duplicate-entry/2175034>\
**Category:** Questions about Thunkable X\
**Tags:** i\_need\_your\_help\
**Created:** [December 11, 2022, 11:33am UTC](https://community.thunkable.com/t/stop-duplicate-entry/2175034 "2022-12-11T11:33:32Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![tanzir.fahimgs31](https://avatars.discourse-cdn.com/v4/letter/t/f475e1/32.png) [@tanzir.fahimgs31](https://community.thunkable.com/u/tanzir.fahimgs31)\
**Post date:** [December 11, 2022, 11:33am UTC](https://community.thunkable.com/t/stop-duplicate-entry/2175034/1 "2022-12-11T11:33:32Z")

</div>

Hi,  
I want to prevent user to enter duplicate entry. I have two criteria. First if user id and date (given by user) match database(google sheet) and second if both user id & date are in same row. If data match and in same row that means data already submitted and user gets alert “Data already exists.” If not updated database.

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [December 11, 2022, 12:58pm UTC](https://community.thunkable.com/t/stop-duplicate-entry/2175034/2 "2022-12-11T12:58:09Z")

</div>

You are already spelling out the logic of your project. Now put this logic in Thunkable blocks and show what you tried if you did not get the expected results.

---

<div class="post-metadata">

**Author:** ![tanzir.fahimgs31](https://avatars.discourse-cdn.com/v4/letter/t/f475e1/32.png) [@tanzir.fahimgs31](https://community.thunkable.com/u/tanzir.fahimgs31)\
**Post date:** [December 12, 2022, 11:50am UTC](https://community.thunkable.com/t/stop-duplicate-entry/2175034/3 "2022-12-12T11:50:41Z")

</div>

How to get row id that contains both user id & date provided by the user. And use that row id to call alert. I am new to thunkable so I don’t know all the blocks yet.

---

<div class="post-metadata">

**Author:** ![tanzir.fahimgs31](https://avatars.discourse-cdn.com/v4/letter/t/f475e1/32.png) [@tanzir.fahimgs31](https://community.thunkable.com/u/tanzir.fahimgs31)\
**Post date:** [December 15, 2022, 3:38pm UTC](https://community.thunkable.com/t/stop-duplicate-entry/2175034/4 "2022-12-15T15:38:09Z")

</div>

@muneer I can start a loop and it can search for duplicate data but I don’t know how to stop this loop when the list is over and if a duplicate is not found what to do. I have shared my project link and my database screenshot. this app is meant to use for daily report submission. where a team of people will submit their report So the same user Id would have multiple reporting dates. I need help to solve this as I am unable to understand.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/8/4/84ca769138689bca7de76d1813c9ed08c409f288.png)

[https://x.thunkable.com/copy/24c5d314936fe18c45016b3b15541ec9](https://x.thunkable.com/copy/24c5d314936fe18c45016b3b15541ec9)

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [December 16, 2022, 1:09am UTC](https://community.thunkable.com/t/stop-duplicate-entry/2175034/5 "2022-12-16T01:09:16Z")

</div>

Am I understanding this correctly?

1. If the user enters data that doesn’t **exactly** match **all** of the row data, it should be allowed
2. If the user enters data that **exactly** matches **all** of the row data, it should not be allowed

And if that’s true, is this also true?

1. A user who entered 4211102193 Dec 15, 2022 true Dec 15, 2022 Dec 15, 2022 for the columns in the screenshot would **NOT** be allowed to enter that as a new r

Because if that’s also true, I think you can just compare row objects and loop through them which might simplify this process.

---

<div class="post-metadata">

**Author:** ![tanzir.fahimgs31](https://avatars.discourse-cdn.com/v4/letter/t/f475e1/32.png) [@tanzir.fahimgs31](https://community.thunkable.com/u/tanzir.fahimgs31)\
**Post date:** [December 13, 2022, 11:05am UTC](https://community.thunkable.com/t/stop-duplicate-entry/2175034/6 "2022-12-13T11:05:47Z")

</div>

I using google sheet as my app database. **I want to check if any single row in my database contains “User Id” and “Dates”.**

![Background](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/6/5/65ad50f1a4d29ad851722264850b1e7d8d873ec1.jpeg)

Which block should I use for checking any single row id at a time also looking for 3 variables in three different column? I am new to thunkable so I have yet to understand all the blocks. If anyone can visually show me that would greatly help my project.

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [December 13, 2022, 3:43pm UTC](https://community.thunkable.com/t/stop-duplicate-entry/2175034/7 "2022-12-13T15:43:27Z")

</div>

You can use the Does List Contain block in the List drawer (see documentation [here](https://docs.thunkable.com/lists)) and List of Values block (see documentation [here](https://docs.thunkable.com/data-sources)) in the Data Sources drawer to check each column for certain values.

If you have trouble, post a screenshot of your blocks and someone may be able to help.

---

<div class="post-metadata">

**Author:** ![tanzir.fahimgs31](https://avatars.discourse-cdn.com/v4/letter/t/f475e1/32.png) [@tanzir.fahimgs31](https://community.thunkable.com/u/tanzir.fahimgs31)\
**Post date:** [December 14, 2022, 3:01pm UTC](https://community.thunkable.com/t/stop-duplicate-entry/2175034/8 "2022-12-14T15:01:05Z")

</div>

![Background](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/5/a52c509a0dcc9cf84b347e09cca28ce6306b02c4.jpeg)

@tatiang This is how I’m trying to solve but it does not work. I don’t know which block allows me to check one row at a time for multiple columns (such as “User Id” and “Reporting date”). like after clicking submit button program gets to the database and looks in row number 1 for “user Id” in the User Id Column and “Reporting Date” in the Reporting Date column. If a match is found, show the alert “Data already exists” or check row number 2 and It will continue like this.

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [December 14, 2022, 3:06pm UTC](https://community.thunkable.com/t/stop-duplicate-entry/2175034/9 "2022-12-14T15:06:30Z")

</div>

Okay, those details are helpful. You would do this:

Count with **i** from 1 to number of rows in [data source]  
…if get list item #i from [list of values in APP in Database in UserId] = [stored variable SignIn\_UserId]  
…break out of loop

And then you can use **i** as the value of the row # where the user id was found. You can also access other columns’ data once you have that row #.

**Edit:** Sorry, there’s an easier way! Use the [find first occurence of “”] block:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/3/6/367e568a8757a855de1de071d5e75283b2b6171b.png)

Insert your [list of values] block where the gear/list block is. Insert your [stored variable SignIn\_UserId] where “b” is.

That block will give you the row # you need without requiring a loop. Assign that block’s value to a variable and then use that variable for the row # as I described above.

---

<div class="post-metadata">

**Author:** ![tanzir.fahimgs31](https://avatars.discourse-cdn.com/v4/letter/t/f475e1/32.png) [@tanzir.fahimgs31](https://community.thunkable.com/u/tanzir.fahimgs31)\
**Post date:** [December 14, 2022, 9:17pm UTC](https://community.thunkable.com/t/stop-duplicate-entry/2175034/10 "2022-12-14T21:17:57Z")

</div>

@tatiang I can do the search part and match part as shown in the photo. But how can I stop if not found and create a new row in the database?

 ![Capture](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/8/d/8d6621ab355f6c0bfc77ae44c60e87d7b2a051a6.png)

---

<div class="post-metadata">

**Author:** ![tanzir.fahimgs31](https://avatars.discourse-cdn.com/v4/letter/t/f475e1/32.png) [@tanzir.fahimgs31](https://community.thunkable.com/u/tanzir.fahimgs31)\
**Post date:** [December 14, 2022, 9:24pm UTC](https://community.thunkable.com/t/stop-duplicate-entry/2175034/11 "2022-12-14T21:24:51Z")

</div>

@tatiang If I do what is shown in this photo program does not respond.

 ![21](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/8/6/862797835b92bb3315f841898452df6d6240184d.png)

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [December 14, 2022, 9:39pm UTC](https://community.thunkable.com/t/stop-duplicate-entry/2175034/12 "2022-12-14T21:39:33Z")

</div>

Those screenshots are too small for me to see. But to answer your question, if the row # variable is still 0 when the loop completes or if [find first occurrence] returns 0, then you know that the user ID was not found.

---

<div class="post-metadata">

**Author:** ![tanzir.fahimgs31](https://avatars.discourse-cdn.com/v4/letter/t/f475e1/32.png) [@tanzir.fahimgs31](https://community.thunkable.com/u/tanzir.fahimgs31)\
**Post date:** [December 15, 2022, 3:12pm UTC](https://community.thunkable.com/t/stop-duplicate-entry/2175034/13 "2022-12-15T15:12:58Z")

</div>

@tatiang I can start a loop and it can search for duplicate data but I don’t know how to stop this loop when the list is over and if a duplicate is not found what to do. I have shared my project link and my database screenshot. this app is meant to use for daily report submission. where a team of people will submit their report So the same user Id would have multiple reporting dates. I need help to solve this as I am unable to understand.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/8/4/84ca769138689bca7de76d1813c9ed08c409f288.png)  
[https://x.thunkable.com/copy/24c5d314936fe18c45016b3b15541ec9](https://x.thunkable.com/copy/24c5d314936fe18c45016b3b15541ec9)

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [December 16, 2022, 1:13am UTC](https://community.thunkable.com/t/stop-duplicate-entry/2175034/14 "2022-12-16T01:13:13Z")

</div>

@conroy33 I think it probably makes sense to merge this topic with [Stop Duplicate Entry](https://community.thunkable.com/t/stop-duplicate-entry/2175034).

---

<div class="post-metadata">

**Author:** ![matt\_conroy](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/matt_conroy/32/150843_2.png) [@matt\_conroy](https://community.thunkable.com/u/matt_conroy)\
**Post date:** [December 16, 2022, 2:06pm UTC](https://community.thunkable.com/t/stop-duplicate-entry/2175034/15 "2022-12-16T14:06:32Z")

</div>

This topic has been merged with: [What blocks should I use to look for "User Id" and "Dates" in my database](https://community.thunkable.com/t/what-blocks-should-i-use-to-look-for-user-id-and-dates-in-my-database/2177573)

My first time merging topics 😹 so posts and times may look a little out of order. Be kind, all.

---

<div class="post-metadata">

**Author:** ![tanzir.fahimgs31](https://avatars.discourse-cdn.com/v4/letter/t/f475e1/32.png) [@tanzir.fahimgs31](https://community.thunkable.com/u/tanzir.fahimgs31)\
**Post date:** [December 16, 2022, 6:33pm UTC](https://community.thunkable.com/t/stop-duplicate-entry/2175034/16 "2022-12-16T18:33:43Z")

</div>

@tatiang Thank you for your tremendous support.

1. If the user enters data that doesn’t **exactly** match **ONLY “USER ID” AND “DATE”** **(REGARDLESS OF WHETHER OTHER COLUMNS IN THE DATABASE SUCH AS ON LEAVE/ON DUTY; ON LEAVE FROM; ON LEAVE TO MATCH OR NOT)** of the row data, it should be allowed
2. If the user enters data that **exactly** matches **ONLY “USER ID” AND “DATE”** of the row data, it should not be allowed.

_Loop has to stop where the database row ends._

And if that’s true, is this also true?

1. A user who entered **UDER ID: 4211102193**  **DATE: Dec 15, 2022** for the columns in the screenshot would **NOT** be allowed to enter that as a new row.
2. Else create a new row.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0f59f292712368bce16ff80133ae10de8a6f27e8.png) [@system](https://community.thunkable.com/u/system)\
**Post date:** [March 16, 2023, 6:34pm UTC](https://community.thunkable.com/t/stop-duplicate-entry/2175034/17 "2023-03-16T18:34:26Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
