473,395 Members | 1,464 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,395 software developers and data experts.

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_Initialize()

On Error GoTo Errhandler

Err.Raise vbObjectError + 70004, "User.Initialize"

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 4792

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_Initialize()

On Error GoTo Errhandler

Err.Raise vbObjectError + 70004, "User.Initialize"

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_Initialize()
On Error GoTo Errhandler

Err.Raise vbObjectError + 70004, "User.Initialize"

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
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...
2
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...
25
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...
1
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...
21
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...
17
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...
1
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...
4
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...
4
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.