Duplicate checking in script

I have the following code in a button (most of the code I’ve found somewhere in this forum). This works just how I want EXCEPT if there are two or more duplicates, I’d like to return all of the LogNumbers that could be potential duplicates. Any thoughts? (Sorry for the hard to read format).

If Not viewLookup Is Nothing Then

	Set docLookup = viewLookup.GetDocumentByKey(uidoc.fieldgettext("TIN"), True)



	If Not docLookup Is Nothing Then	

	

		If doc.UniversalID <> docLookup.UniversalID Then



			PotDup = docLookup.LogNumber

'REM There is a duplicate found and it is not itself

IsDocumentDuplicate = True

		End If	

		

	Else

		IsDocumentDuplicate = False

	'REM No hits on the lookup

	End If		

End If	



If IsDocumentDuplicate = True Then

	Messagebox "This is a potential duplicate with " & Cstr(PotDup(0))

Else

	Messagebox "This is not a duplicate"

End If

Subject: Duplicate checking in script

Instead of GetDocumentByKey, use GetAllDocumentsByKey. Then you can loop through them and build a string of all the log numbers [If PotDup = “” then PotDup = cstr(docLookup.LogNumber(0)) else PotDup = PotDup + ", " + Cstr(docLookup.LogNumber(0))].

Regards,

Don