If you take a look at my Custom Forms demo, it handles this (preventing duplicates on edit).
The trick is to set a column in a separate table with the name of the record being edited, then build an array which excludes that name, and then finally use that array to build a relation back to the source table.