473,695 Members | 1,815 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 = acDataErrContin ue
End If

Any assistance would be much appreciated. Thanks.

Nov 13 '05 #1
3 5831
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 = acDataErrContin ue
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:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQzi4EYechKq OuFEgEQJtVQCg9k oc/Omt0qhxAC5AgBv2 rMLpUM8AoO6t
i/N1NdQbvkVHbOm6Q n5mlimh
=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...@megavi sion.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...@dbf orums.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 "qryAppendYourR ecords", 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.SetWarnin gs False to ignore
the query generated error.

--

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

"Rolan" <co******@saf e-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
1279
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 custom interface the exception's error information is lost. The problem appears to be in PyGatewayBase::InterfaceSupportsErrorInfo() in PyGatewayBase.cpp. It is called to determine whether the GetErrorInfo API should be used to extract an error...
9
13898
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 different parts of my site to throw a dummy exception and I always get to the page that says change my web.config to the statement above.
2
1645
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 basically that the method that I've designated as the validation routine never gets called so I can't do anything about potentially duff data. I've declared the custom control as:
5
2539
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 "Enlighten.LinkMad.Businesslogic". In one of my frontend websites I use this type to authenticate a user who is trying to login. The following excerpt is from the web.config of the particular site showing the reference to the custom provider, allowing .Net to do...
8
5034
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 select, remember it, and then use it in the update. It works just fine when I have full control of the whole process. I want to do the same for my GridView/SqlDataSource combinations. I typically select from a view and update the corresponding...
1
4137
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. When I attached the debugger to the process and stepped into the code it executed without error. In both cases I was running a Debug build, the only difference in the case that works is that I attached the debugger to the same exact binaries....
3
7274
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 spaces, such as: My Install Folder\SetupDir The exception thrown is:
1
2285
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 works fine. But when I define a skinID for this Custom Control, I am getting an error when it compiles. I tried adding the Register directive in the skin file but that doesnot help.
2
2830
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 newsgroups that i should set the noImpersonate bit in the MSI file and that I need Orca for that. So I did. I have found the custom action and added 3584 to the Type field of 1025, like I read in...
0
8565
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9113
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7656
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6488
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5837
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4339
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2997
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2269
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1971
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.