[AccessD] Err object

John Colby jwcolby at ColbyConsulting.com
Mon Nov 21 12:09:18 CST 2005


I know what it says, but I have tested this.  Apparently "within" also means
(includes) if you call a function from WITHIN and that function encounters
an Exit statement.

I have code that goes out and gets pointers to my framework class, then a
class within the framework class etc.

cFW.cErrHndlr.Err()

Before I get to the .Err the error object has been reset.  I have stepped
through the code and it was upon exiting one of the calls that the error was
reset and after that point the values were 0.  It may very well be a bug in
the way the err object is handled, but it IS happening and I have to code
around it.

I have built an error handler function that immediately initializes a clsErr
to store all the attributes of the error object and then calls the init of
that class.  The class simply copies the Err properties into variables in
the class header.  

John W. Colby
www.ColbyConsulting.com 

Contribute your unused CPU cycles to a good cause:
http://folding.stanford.edu/

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Heenan, Lambert
Sent: Monday, November 21, 2005 12:46 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Err object


Not so!

HELP says...
"The Err object's properties are reset to zero or zero-length strings ("")
after an Exit Sub, Exit Function, Exit Property or Resume Next statement
within an error-handling routine. Using any form of the Resume statement
outside of an error-handling routine will not reset the Err object's
properties. The Clear method can be used to explicitly reset Err."

Note the comment about using Exit Sub, Exit Function or Exit Property
*WHITHIN* the error handler.

Run this code to see that the error information is preserved across a call
to an external routine which uses "Exit Sub"...

Sub ErrTest()
Dim n As Long

   On Error GoTo ErrTest_Error
    
    n = 100 / 0
   
   On Error GoTo 0
   Exit Sub

ErrTest_Error:
    MsgBox Err.Number & ": " & Err.Description, , "ErrTest"
    DoSomthing
    MsgBox Err.Number & ": " & Err.Description, , "ErrTest"
End Sub

Sub DoSomthing()
Dim n As Long
    For n = 1 To 10
        Debug.Print n
        If n = 5 Then Exit Sub
    Next n
End Sub

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Dan Waters
Sent: Monday, November 21, 2005 12:22 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Err object


I should have added that as soon as you do anything with an Err object's
properties, it's value goes away.

So, after setting GlngErrNumber = Err.Number, the value of Err.Number is no
longer available.

Dan Waters

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of John Colby
Sent: Monday, November 21, 2005 10:54 AM
To: 'Access Developers discussion and problem solving'
Subject: [AccessD] Err object

I have just discovered that the error object resets the first time an end
sub/function is encountered.  Thus I cannot even call a function to return
my framework class instance since the return of that call clears the error
handler.

Any comments on how you folks handle error logging given this issue?

John W. Colby
www.ColbyConsulting.com 

Contribute your unused CPU cycles to a good cause:
http://folding.stanford.edu/

-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list