James
asked on
Override Access's default error message when a duplicate value is entered
I have a users form based on a users table where the primary key is the username. I'd like to add code to give my own error message when a duplicate username is entered instead of Access's default error message.
Is it preferable to put this code in the BeforeUpdate event of the control or the form? Or somewhere else?
Can anyone provide me with sample code?
Thank you!
Is it preferable to put this code in the BeforeUpdate event of the control or the form? Or somewhere else?
Can anyone provide me with sample code?
Thank you!
The Duplicate Error is only rendered in the Form Error event. Consequently, you will need to trap that error number there, wherein you can display your own error message.
Note that Errors rendered in the Form Error event occur before the Before Update event.
mx
Note that Errors rendered in the Form Error event occur before the Before Update event.
mx
ASKER
Thanks for the suggestions so far. Allow me to be a little clearer about what I'm looking for.
If someone duplicates a username (either by entering a new duplicate or changing an existing one), I'd like to pop up an error message of my own. I currently have no preference if the warning pops up as soon as the duplicate is entered or if it pops up when Access tries to update the table (either through a save button, switching records, or closing the form).
At no point do I want to see Access's error message.
So my questions are:
1. Is it better to display the warning as soon as the duplicate is entered or to display it when the form attempts to update the record?
2. Can someone provide me with an appropriate code sample?
Thanks again!
If someone duplicates a username (either by entering a new duplicate or changing an existing one), I'd like to pop up an error message of my own. I currently have no preference if the warning pops up as soon as the duplicate is entered or if it pops up when Access tries to update the table (either through a save button, switching records, or closing the form).
At no point do I want to see Access's error message.
So my questions are:
1. Is it better to display the warning as soon as the duplicate is entered or to display it when the form attempts to update the record?
2. Can someone provide me with an appropriate code sample?
Thanks again!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Thanks, Joe.
You are right.
Sincerely,
Ed
You are right.
Sincerely,
Ed
Normally control events looks for things like format and form events look for things like duplicates, so put it on the form level.
Hope it helps. Regards.