Ironis
12-26-2002, 06:42 AM
Hi,
I want to create my own error message on a duplicate record. The problem with the normal error message, is that the text is very long, and for users sometimes not understandable. So I want to create an error message, with 'normal' language, instead of the technical error message there is in Access.
Does anyone know the error number of this error message??
chenn
12-26-2002, 10:30 AM
I do not know the error number off hand, however it is easy enough to find. On your error handling, put in something like:
msgbox err.number & err.description
Then force the error to occur. When it does, you will get the error number and text of what happened. Next in your error handler, add some code to trap it. For example:
Private sub TEST()
on error goto HandleErrors 'turn on your error handling
'This error handler should be placed at the end of the sub where the error may occur
HandleErrors:
If err.number = 2011 then 'your newly found number
msgbox "This is your new error text."
'put in what you want to do next here IE:
Textbox = ""
Textbox.setfocus
'etc....
Else
'here is your normal error handling for all other errors
msgbox err.description
end if
end sub
Ironis
12-26-2002, 12:55 PM
Tanks, the last part i knew, but thanks for explaining :) Now I will find the right number i guess!
Thanks again,
Ironis :cool:
Ironis
12-26-2002, 01:00 PM
Hmm, just tested it, got some errors, but the Duplicate Record seems to be no error, becouse it appears in its own form, without an error number.
The title of the box says "Microsoft Access", but still I'd like to have my own textbox there.
Does anyone know how to capture this event??
WayneRyan
12-27-2002, 09:35 AM
Ironis,
I think that you will have to test for it on your form.
Use the OnChange or AfterUpdate event on the field that
contains your primary key. Use the DLookUp function to check
if it is present in your data. If it is present, display a MsgBox
or clear the field or whatever.
Wayne
p.s. Still researching the swimmers.