- Local time
- Yesterday, 22:08
- Joined
- Feb 19, 2002
- Messages
- 46,873
It is important that you use the correct event to do your validation. If you are looking for a duplicate and this is a SINGLE field, you put your DCount() expression in the BeforeUpdate event of the CONTROL where the value is entered. If there is a duplicate, you cancel the event. I rarely delete what the user has typed. It is more user friendly to let him see his typo. You would have to show us the code that was causing the can't go to record error.The further problem that that created and another error I was getting have disappeared by moving the code to "On Got Focus" event of the "Hours" field. The duplicate record check is performed clear the data then set focus to the first field of the form.
If the duplicate is defined by a combination of fields, then the only realistic way to validate is to use the FORM's BeforeUpdate event. The code is essentially the same and you STILL have to CANCEL the event.
The event you have settled on is incorrect. If you don't actually cancel the saving of the record, the bad data will get saved unless the database engine raises an error. Understanding which event to use for which purpose is critical in building solid applications.