As Lars pointed out, you should use the ItemChanged event. It triggers when the field has been changed and before it is stored in the buffer. You logic can accept or reject the changes and prevent or allow the focus to change to a different field. Keep in mind that in a multi-user environment the only way to ensure you won't have duplicate values stored is checking the database right before inserting the values. In other words, when you check for duplicates in the ItemChanged event there might not be one, but another user can insert the same one just before you do.
↧