473,324 Members | 2,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Custom Error Message Fails to Work

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.

Nov 13 '05 #1
3 5784
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-----
Nov 13 '05 #2
Sorry if I did not clarify the post, but this is not related to a
user-defined error number. Error 10011 is a bonafide MS Access (97)
Error number, and regardless of what error trap that has been
constructed, so that a user-designed error message can be shown, the MS
Access default error message is displayed instead (database was unable
to append all the data to the table...) Is this an unknown bug or what?
Below is a related post that I found in the archives that describes the
same phenomenon; however, I have spent considerable time writing error
trapping code, but with no success.

Anyone's insight will be appreciated.
Newsgroups: comp.databases.ms-access
From: soare...@qatar.net.qa (Edward S) - Find messages by this author
Date: 12 Apr 2003 07:16:25 -0700
Local: Sat, Apr 12 2003 10:16 am
Subject: Customs Message instead of the Access Message

I have a button which runs a code to import data from an Excel
spreadsheet to a table
in Access, however when it finds that the data to import already exits,

a message pops like this "Access was unable to append all the data to
the table ............ " . I do not want this message, but want to
replace it with a message like "The file you are trying to import has
already been imported before, please check and try again"
How can I accomplish this. Could someone point me in the right
direction
Regards
Ed

Michael Bragg Apr 12 2003, 11:54 am

Newsgroups: comp.databases.ms-access
From: "Michael Bragg" <pmbr...@megavision.com>
Date: Sat, 12 Apr 2003 10:54:42 -0500
Local: Sat, Apr 12 2003 11:54 am
Subject: Re: Customs Message instead of the Access Message
I think you can use your On Error Goto feature. This will allow you to
go to
any error message that you want to.
HTH
Michael

Rockey Apr 12 2003, 2:25 pm

Newsgroups: comp.databases.ms-access
From: Rockey <member1...@dbforums.com>
Date: Sat, 12 Apr 2003 17:58:19 +0000
Local: Sat, Apr 12 2003 1:58 pm
Subject: Re: Customs Message instead of the Access Message
Correct-
Reproduce the error to grab the error number. Then substitute the
number for ###.
Private Sub DoSomething()
On Error GoTo PROC_ERR
PROC_EXIT:
Exit Sub
PROC_ERR:
Debug.print Err.Number
If Err.Number = ### Then
MsgBox "Access was unable to append all the data to
the table ............ "
Else
MsgBox Err.Description
End If
Resume PROC_EXIT

Nov 13 '05 #3
Well, my syntax is probably wrong cause I'm doing this off the top of my
head, but I think you need to do something like this ...

Dim dbs As DAO.Database
Set dbs = CurrentDB()
dbs.Execute "qryAppendYourRecords", dbFailOnError

I think I've used this syntax to accomplish what you describe, but whatever
you do, the FailOnError flag needs to be set for it to pass the error to your
error handler. You may need to add a DoCmd.SetWarnings False to ignore
the query generated error.

--

Danny J. Lesandrini
dl*********@hotmail.com
http://amazecreations.com/datafast/

"Rolan" <co******@safe-mail.net> wrote ...
Sorry if I did not clarify the post, but this is not related to a
user-defined error number. Error 10011 is a bonafide MS Access (97)
Error number, and regardless of what error trap that has been
constructed, so that a user-designed error message can be shown, the MS
Access default error message is displayed instead (database was unable
to append all the data to the table...) Is this an unknown bug or what?
Below is a related post that I found in the archives that describes the
same phenomenon; however, I have spent considerable time writing error
trapping code, but with no success.

Anyone's insight will be appreciated.

Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Philip Rittenhouse | last post by:
I have one last issue with pywin32 to report. The problem occurs with Python COM servers raising COM exceptions across a custom interface. Using the dispatch interface works fine, but in the...
9
by: Nick | last post by:
the customError feature is not working. I have it setup as the help says in my web.config file. <customErrors defaultRedirect="DsAppError.aspx" mode="RemoteOnly"/> I tried in a couple...
2
by: SimonH | last post by:
Hi All, I'm having problems getting a custom validator to work. I'm hoping someone could perhaps notice what I've missed. I only want to provide a server side validation method. The problem is...
5
by: Graham | last post by:
I have created a custom MembershipProvider called "LassieMembershipProvider" that derives from "MembershipProvider". This providor is located in a Businesslogic layer dll called...
8
by: Mike Kelly | last post by:
I've chosen to implement the "optimistic concurrency" model in my application. To assist in that, I've added a ROWVERSION (TIMESTAMP) column to my main tables. I read the value of the column in my...
1
by: David Herbst | last post by:
Enterprise Library Jan 2006 with Visual Studio 2005 on Windows 2000 Server sp4. My custom exception formatter fails with a "Unable to handle exception: 'LoggingExceptionHandler'." exception. ...
3
by: Eric | last post by:
Using VS.Net 2003 .Net framework 1.1 SP1 Our installation project calls a Custom Action dll to perform post install actions. It fails if the .msi file is launch from a directory that contains...
1
by: aspnet20vb_mike | last post by:
I have a Custom Control which inherits from GridView. I call it GridViewSort and it is in a namespace "PDS.WebControls". I add it to the Toolbox, drop it on my WebForm and it shows up and...
2
by: incrediblesuperdude | last post by:
Hi! I have a deployment project made with Visual Studio 2003. The setup fails when I run it in Vista. I have figured out that it only fails when I have an Install Custom Action. I have read in...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.