473,660 Members | 2,426 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Class returns 440 - automation error

Hello,

I know this must be something simple I'm overlooking but I can't get
err.raise inside a class to return anything but 440 - automation
error. For example, if I create the following test class:

Option Compare Database
Option Explicit

Private Sub Class_Initializ e()

On Error GoTo Errhandler

Err.Raise vbObjectError + 70004, "User.Initializ e"

Exit Sub

Errhandler:

Err.Raise Err.Number, Err.Source, Err.Description

End Sub

and then use the following code to test it:

Sub testitout()

Dim x As clsTest

On Error GoTo Errhandler

Set x = New clsTest

Exit Sub

Errhandler:

Err.Raise Err.Number, Err.Source, Err.Description

End Sub

When I call testitout() from the debug window I get an error message
saying 'run time error 440: automation error' instead of my custom
error. What do I need to do to have the caller of my class raise my
custom error instead of the generic 440 automation error? Thanks.

Bruce

Feb 16 '07 #1
1 4811

Bruce wrote:
Hello,

I know this must be something simple I'm overlooking but I can't get
err.raise inside a class to return anything but 440 - automation
error. For example, if I create the following test class:

Option Compare Database
Option Explicit

Private Sub Class_Initializ e()

On Error GoTo Errhandler

Err.Raise vbObjectError + 70004, "User.Initializ e"

Exit Sub

Errhandler:

Err.Raise Err.Number, Err.Source, Err.Description

End Sub

and then use the following code to test it:

Sub testitout()

Dim x As clsTest

On Error GoTo Errhandler

Set x = New clsTest

Exit Sub

Errhandler:

Err.Raise Err.Number, Err.Source, Err.Description

End Sub

When I call testitout() from the debug window I get an error message
saying 'run time error 440: automation error' instead of my custom
error. What do I need to do to have the caller of my class raise my
custom error instead of the generic 440 automation error? Thanks.

Bruce

I see that you are trying to raise an error 3 times in your code, but
you are not trying to do anything with it.
Your error number would be -2147151500 which I don't think is a
recognized number and since you are not doing anything with that
number ( ex. no MsgBox statement ) Access applies the Automation Error
message. The class is in effect an automation object and there was an
error in it. You need to spend a little more time reading into some of
the tips and tricks of error handling.
You example should look more like

---------------------------------------------------------------
Private Sub Class_Initializ e()
On Error GoTo Errhandler

Err.Raise vbObjectError + 70004, "User.Initializ e"

exit_here:
Exit Sub

Errhandler:
MsgBox Err.Description , vbOKCancel, Err.Number & " in " &
Err.Source
'Err.Raise Err.Number, Err.Source, Err.Description 'Commented
out
Resume exit_here
End Sub

-------------------------------------------------

Sub testitout()

Dim x As clsTest

On Error GoTo Errhandler

Set x = New clsTest

exit_here:
Set x = Nothing
Exit Sub

Errhandler:
Resume exit_here
'Err.Raise Err.Number, Err.Source, Err.Description 'Commented
out
End Sub

Feb 18 '07 #2

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

Similar topics

3
8867
by: Robert | last post by:
---EN--- This message has been crossposted in a french speaking newsgroup, english version is at the end. Thanks a lot for your help... --/EN--- Bonjour, Je développe une application intranet qui "tourne" maintenant depuis plusieurs années auprès de 2500 personnes environ, mais depuis 1 mois,
2
4334
by: Andante.in.Blue | last post by:
Our Access 97 database is a single-file (non-splitted, pure Access) hosted no a network server, accessed regularly by a handful of users around the office. Until recently (until the Great Blackout, actually), there have been no problem with the database. It seems to handle simultaneous users fine and did not cause any grief. The blackout corrupted the DB, but we restored a pre-blackout version, so everything was good for a while.
25
3717
by: Neil Ginsberg | last post by:
I have a strange situation with my Access 2000 database. I have code in the database which has worked fine for years, and now all of a sudden doesn't work fine on one or two of my client's machines. The code opens MS Word through Automation and then opens a particular Word doc. It's still working fine on most machines; but on one or two of them, the user is getting an Automation Error. The code used is as follows: Dim objWord As...
1
808
by: Jimmer | last post by:
I've got what should be an easy automation problem, but the solution simply isn't coming to me. I've got several public variables set up for automation as follows: Public gappExcel As Excel.Application 'ADO Object for Excel Automation Public gstrExcelDir As String 'Source or Destination Directory
21
2550
by: Neil | last post by:
Is there a way to trap an error generated in another app that is controlled via automation? I have an Access 2000 app that opens Word 2000 and proceeds to open a series of documents and, in each document, parse the contents and write it to an Access table (the Access app, after opening Word, runs a macro within Word which parses and writes to the Access app via DAO). Occasionally we get an error from Word (such as "document is locked for...
17
3591
by: Joe | last post by:
Hello All; I can't access System.Web.HttpServerUtility from within a Class. I want to have access to MapPath. What I get are three options. They are: AspNetHostingPermission AspNetHostingPermissionAttributes AspNetHostingPermissionLevel
1
2313
by: Joe | last post by:
Hello All, I have a class that inherits from System.Web.UI.Page. In it I call the Page.LoadControl. I am having trouble with the virtual path that the LoadControl method accepts as its parameter. I have the following code in a method call: Dim uControl As CustomAddresses = CType(Page.LoadControl("../UserControls/CustomAddresses.ascx"),
4
6213
by: jayesah | last post by:
Hi All, I am writting a Thread class with using pthread library. I have some problem in saving thread function type and argument type. How to make Thread class generic ? /* This is my global Function */ template < class FunType, class ArgType> Thread makeThread(Funtype fun, ArgType arg)
4
5464
by: =?Utf-8?B?QmFkaXM=?= | last post by:
Hi, I'm using automation and it's working fine when I run it from my local machine. but if I try to access it from another machine it's giving me this Error: Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80070005.
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8851
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
8630
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7362
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...
0
5650
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
4177
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...
0
4343
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1984
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1740
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.