A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

More Understandable Error Message



 
 
Thread Tools Display Modes
  #1  
Old December 6th, 2008, 02:16 AM posted to microsoft.public.access.tablesdbdesign
Ken Hudson
external usenet poster
 
Posts: 82
Default 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  
Old December 6th, 2008, 02:42 AM posted to microsoft.public.access.tablesdbdesign
Allen Browne
external usenet poster
 
Posts: 11,706
Default 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  
Old December 6th, 2008, 03:42 AM posted to microsoft.public.access.tablesdbdesign
fredg
external usenet poster
 
Posts: 4,386
Default 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  
Old December 6th, 2008, 04:16 AM posted to microsoft.public.access.tablesdbdesign
Ken Hudson
external usenet poster
 
Posts: 82
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:17 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.