If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
More Understandable Error Message
I have a table in which I have set up a unique index based on two fields.
When a user tries to enter the same data twice through a form, they get the generic message about duplicating the index, primary key, etc. Is there a way to customize this error message? -- Ken Hudson |
#2
|
|||
|
|||
More Understandable Error Message
You can trap the message in the Error event of your form, and substitute it
with something more meaningful. (Of course, it won't tell you *which* unique index is violated, so you will need to determine that for yourself.) -- Allen Browne - Microsoft MVP. Perth, Western Australia Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. "Ken Hudson" wrote in message ... I have a table in which I have set up a unique index based on two fields. When a user tries to enter the same data twice through a form, they get the generic message about duplicating the index, primary key, etc. Is there a way to customize this error message? -- Ken Hudson |
#3
|
|||
|
|||
More Understandable Error Message
On Fri, 5 Dec 2008 18:16:01 -0800, Ken Hudson wrote:
I have a table in which I have set up a unique index based on two fields. When a user tries to enter the same data twice through a form, they get the generic message about duplicating the index, primary key, etc. Is there a way to customize this error message? You can use code to replace the system message with your own. Here's how you can find the correct error and show your own message for any of the form level errors. First code the Form's Error event: MsgBox "Error#: " & DataErr ' Display the error number Response = acDataErrDisplay ' Display Default message Then open the form and intentionally make that error. The message box will display the error number and the default error message. Next, go back to the error event and change that code to: If DataErr = XXXX Then Response = acDataErrContinue ' Don't display the default message MsgBox "Present your own user friendly message here." Else MsgBox "Error#: " & DataErr Response = acDataErrDisplay ' Display Default message End If where XXXX is the error number. -- Fred Please respond only to this newsgroup. I do not reply to personal e-mail |
#4
|
|||
|
|||
More Understandable Error Message
Perfect!
Thanks Fred. -- Ken Hudson "fredg" wrote: On Fri, 5 Dec 2008 18:16:01 -0800, Ken Hudson wrote: I have a table in which I have set up a unique index based on two fields. When a user tries to enter the same data twice through a form, they get the generic message about duplicating the index, primary key, etc. Is there a way to customize this error message? You can use code to replace the system message with your own. Here's how you can find the correct error and show your own message for any of the form level errors. First code the Form's Error event: MsgBox "Error#: " & DataErr ' Display the error number Response = acDataErrDisplay ' Display Default message Then open the form and intentionally make that error. The message box will display the error number and the default error message. Next, go back to the error event and change that code to: If DataErr = XXXX Then Response = acDataErrContinue ' Don't display the default message MsgBox "Present your own user friendly message here." Else MsgBox "Error#: " & DataErr Response = acDataErrDisplay ' Display Default message End If where XXXX is the error number. -- Fred Please respond only to this newsgroup. I do not reply to personal e-mail |
Thread Tools | |
Display Modes | |
|
|