Heenan, Lambert
Lambert.Heenan at AIG.com
Mon Nov 21 11:45:49 CST 2005
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