Charlotte Foust
cfoust at infostatsystems.com
Wed Aug 9 17:07:50 CDT 2006
I should have caught that the first time. Using Resume Next means that
all errors in the routine get absorbed, including the ones you try to
raise.
Charlotte Foust
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Bobby Heid
Sent: Wednesday, August 09, 2006 11:59 AM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Raising errors...
Charlotte,
Thanks for the pointers.
What I was doing was using resume next and looking at the error code
myself and deciding whether or not to raise the same error.
So I went back and used an error handler and had the logic in the error
handler to raise the error again and it works as I expected.
Thanks again,
Bobby
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Charlotte
Foust
Sent: Tuesday, August 08, 2006 5:21 PM
To: Access Developers discussion and problem solving
Subject: [SPAM SUSPECT] Re: [AccessD] [SPAM SUSPECT] Re: [SPAM SUSPECT]
Re:
Raisingerrors...
Importance: Low
Bobby,
I just looked at your code again instread of just at the error handling.
You have On Error Resume Next set, which clears the error. If you want
to raise an error, you have to use an error handler and raise the error
from there.
Charlotte Foust
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Bobby Heid
Sent: Tuesday, August 08, 2006 1:42 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] [SPAM SUSPECT] Re: [SPAM SUSPECT] Re:
Raisingerrors...
A class object.
Bobby
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Charlotte
Foust
Sent: Tuesday, August 08, 2006 4:31 PM
To: Access Developers discussion and problem solving
Subject: [SPAM SUSPECT] Re: [AccessD] [SPAM SUSPECT] Re: Raising
errors...
Importance: Low
I'ts what happens in .Net, but I don't remember how it works in Access.
Is the error occurring in a class object or a standard module?
Charlotte Foust
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Bobby Heid
Sent: Tuesday, August 08, 2006 12:59 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] [SPAM SUSPECT] Re: Raising errors...
Hi Charlotte,
No I have not. Is there not a way to bubble the error up to the calling
routine as if the error happened there?
Thanks,
Bobby
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Charlotte
Foust
Sent: Tuesday, August 08, 2006 3:52 PM
To: Access Developers discussion and problem solving
Subject: [SPAM SUSPECT] Re: [AccessD] Raising errors...
Importance: Low
Raising errors only bumps them up to the next level. It's a somewhat
passive action. You have to check for the raised error in the calling
routine. Have you done that?
Charlotte Foust
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Bobby Heid
Sent: Tuesday, August 08, 2006 12:15 PM
To: 'Access Developers discussion and problem solving'
Subject: [AccessD] Raising errors...
I tried to find information in the archives but could not.
I have a class that I am using to handle the opening of databases and
one of the opens a database and returns a database variable. This works
well.
In the original code, there was error handling in place to handle
'database is opened exclusively by someone...', and other errors. So in
replacing the opendatabase call with my class call, I would like the
class to raise any errors so that it propagates back to the calling
function.
There are several older passwords that I have to keep track of.
I tried something like this:
Public Function OpenDB(ByVal strDBName As String, ByVal bOpenExclusive
As Boolean, ByVal bRO As Boolean) As Database
Dim db As Database
Dim i As Long
On Error Resume Next
Set OpenDB = Nothing 'init the db return
value
For i = 0 To NUMPWS - 1
Set db = Workspaces(0).OpenDatabase(strDBName, bOpenExclusive,
bRO, ";pwd=" & mstrPW(i))
If Err.Number = 0 Then 'if =0 then good open
Set OpenDB = db
Exit For
End If
If Err.Number <> 3031 Then 'some error other than invalid pw
Err.Raise Err.Number, "clsPW.OpenDB", Err.Description
Else
'if we're on the last pw, and it is invalid, raise an
error
If i = NUMPWS - 1 Then 'last one
Err.Raise 3031, "clsPW.OpenDB", "Invalid password"
End If
End If
Next i
Proc_Exit:
Exit Function
End Function
It executes the err.raise statement as I expected, but nothing happens.
Am I misunderstanding the raise event?
Thanks,
Bobby
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com