Duplicate Documents

I want to program a form where if a document exists which is exactly like the one a user is trying to create, an error should display. How should I go about doing this? I am thinking the form should somehow search each field and match it with the one the user is trying to create; if all fields match in a document, then display the error. Has anyone done this before or have an idea as how to start this code?

Subject: Duplicate Documents

I’ve only done this via a button. So when the user clicks the button (which has the compose option), but it runs through and checks some stuff before it executes the @compose function. Let me know if you want a sample. Email me.