Rolan wrote:
I seem to be unable to have a custom error message to appear for Error
10011 (database was unable to append all the data to the table). Each
time, the MS Access default error message box appears. The reason for
the error is to prevent an import of a record of which one already
exists based on a like item number.
I tried various methods of structuring an error handler in the sub,
including Select Case, but with no success. I assume that the Form - On
Error procedure should be used instead, but that has not worked either.
Const AddDataError = 10011
If DataErr = AddDataError Then
MsgBox "The item number associated with the record already exists in
the database."
Response = acDataErrContinue
End If
Any assistance would be much appreciated. Thanks.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
To use user-defined error numbers you have to raise the error yourself:
On Error Resume Next
' do something that may cause an error condition that you want
' your error to show
If err > 0 Then
Err.Raise AddDataError,,"My error msg"
End If
Usually a number is added to a built-in intrinsic constant. Something
like this:
vbObjectErr + 512 [or whatever number you want]
Err.Raise vbObjectErr + AddDataError, , "My Error Msg"
If err = vbObjectErr + AddDataError Then ...
This is to allow future versions of Access to increase the number of
built-in error numbers w/o affecting user-defined error numbering.
See the Access VBA Help articles on Err.Raise for more info.
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/AwUBQzi4EYechKqOuFEgEQJtVQCg9koc/Omt0qhxAC5AgBv2rMLpUM8AoO6t
i/N1NdQbvkVHbOm6Qn5mlimh
=pkex
-----END PGP SIGNATURE-----