John Colby
jwcolby at ColbyConsulting.com
Mon Nov 21 12:33:23 CST 2005
OK, a little further investigation: I set up this code to watch the process: Debug.Print Err.Number On Error GoTo Err_mEr Debug.Print Err.Number Dim lclsErr As clsErr Debug.Print Err.Number Set lclsErr = New clsErr Debug.Print Err.Number I already had the OnError GoTo in place (My error handler insertion builder adds it as it builds the error handler). THAT statement resets the error object. All I had to do was rearrange my code to run the On error resume next to after I captured the error in my class and all works just peachy. The help doesn't mention On Error goto SomeLabel as resetting the err object but it apparently does. 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