cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ajennings1
Resolver I
Resolver I

Check if exactly the same record exists SQL

I have a situation where an admin can add users to a Project Users table in an Azure SQL DB. They choose the user, the project and their role within the project. I don't want them to be able to add the same person with the same role to the same project basically. What would be the easiest way to check the form entries and see if a record that has those exact same row values exist.

 

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
Pstork1
Dual Super User III
Dual Super User III

I would do a lookup using the three fields.  If the result is null (empty) then you don't have a record like that.  If the result isn't empty then you do.  If the result contains more than one record then you already have duplicates.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

3 REPLIES 3
Pstork1
Dual Super User III
Dual Super User III

I would do a lookup using the three fields.  If the result is null (empty) then you don't have a record like that.  If the result isn't empty then you do.  If the result contains more than one record then you already have duplicates.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

@Pstork1,

 

Thanks for that! I used this code to check for duplicates for reference: 

If(Lookup(Source, ColOneID = val && ColTwoID = val etc., "Repeat") <> "Repeat", SubmitForm(Form1), showErrorMsg)

Pstork1
Dual Super User III
Dual Super User III

Just to call out the obvious.  Your val to match would actually be different values for each column.  Otherwise I think that should work.  One other thing to add.  I looked later and Lookup only returns the first hit.  It won't help you find duplicates.  For that you would need to use Search.  For your purposes I think Lookup will do just fine.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

secondImage

Power Apps Community Call

Please join us on Wednesday, October 20th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Users online (1,568)