Error Handler -- Getting Line Number of error 
Author Message
 Error Handler -- Getting Line Number of error

Hi All,

I'd like to design a VBA error handler based on where an error occurs, and take appropriate action.  In some languages there is a function to return the actual line number where the error occurred, and also the source code statement that caused the error.

Is this possible in VBA?  If so, can anyone give me some guidance or direct me to a source that will show how to do this?

If not, please direct me to some sources for developing good VBA error handlers.

TIA.

Best Regards,
jmu

J. M. Underwood
Apollo Information Systems, Inc.
Houston, TX




Sat, 24 Jan 2004 04:17:14 GMT  
 Error Handler -- Getting Line Number of error
Jim, you need to use the Erl Function. Sample:

Sub TestError()
101 On Error GoTo ERR_Handler
102 Err.Raise "100"
103
104 Finally:
105  Exit Sub
106 ERR_Handler:
107     Debug.Print Erl
End Sub

The key is you have to line number the code.

--
Chris Kunicki
www.OfficeZealot.com


Hi All,

I'd like to design a VBA error handler based on where an error occurs, and
take appropriate action.  In some languages there is a function to return
the actual line number where the error occurred, and also the source code
statement that caused the error.

Is this possible in VBA?  If so, can anyone give me some guidance or direct
me to a source that will show how to do this?

If not, please direct me to some sources for developing good VBA error
handlers.

TIA.

Best Regards,
jmu

J. M. Underwood
Apollo Information Systems, Inc.
Houston, TX




Sat, 24 Jan 2004 08:21:05 GMT  
 Error Handler -- Getting Line Number of error
Hi Chris,

Thanks for the reply.

OK this sounds great!

Now, is there a way in the VBA editor to autonumber?

'Cause we all know that nobody is going to manually type line numbers!

Come on Microsoft!  This is basic stuff!!!!

--

Best Regards,
jmu

J. M. Underwood
Apollo Information Systems, Inc.
Houston, TX



Quote:
> Jim, you need to use the Erl Function. Sample:

> Sub TestError()
> 101 On Error GoTo ERR_Handler
> 102 Err.Raise "100"
> 103
> 104 Finally:
> 105  Exit Sub
> 106 ERR_Handler:
> 107     Debug.Print Erl
> End Sub

> The key is you have to line number the code.

> --
> Chris Kunicki
> www.OfficeZealot.com



> Hi All,

> I'd like to design a VBA error handler based on where an error occurs, and
> take appropriate action.  In some languages there is a function to return
> the actual line number where the error occurred, and also the source code
> statement that caused the error.

> Is this possible in VBA?  If so, can anyone give me some guidance or
direct
> me to a source that will show how to do this?

> If not, please direct me to some sources for developing good VBA error
> handlers.

> TIA.

> Best Regards,
> jmu

> J. M. Underwood
> Apollo Information Systems, Inc.
> Houston, TX





Sat, 24 Jan 2004 11:43:05 GMT  
 Error Handler -- Getting Line Number of error
There is not a way, though In the past I have seen utilities that will do it
for you. I just haven't used one. You should do a web search at
groups.google.com to see what you mind find.

The truth is Microsoft would have loved to drop it, but they need it for
backward compatibility.
--
Chris Kunicki
www.OfficeZealot.com


Quote:
> Hi Chris,

> Thanks for the reply.

> OK this sounds great!

> Now, is there a way in the VBA editor to autonumber?

> 'Cause we all know that nobody is going to manually type line numbers!

> Come on Microsoft!  This is basic stuff!!!!

> --

> Best Regards,
> jmu

> J. M. Underwood
> Apollo Information Systems, Inc.
> Houston, TX




> > Jim, you need to use the Erl Function. Sample:

> > Sub TestError()
> > 101 On Error GoTo ERR_Handler
> > 102 Err.Raise "100"
> > 103
> > 104 Finally:
> > 105  Exit Sub
> > 106 ERR_Handler:
> > 107     Debug.Print Erl
> > End Sub

> > The key is you have to line number the code.

> > --
> > Chris Kunicki
> > www.OfficeZealot.com



> > Hi All,

> > I'd like to design a VBA error handler based on where an error occurs,
and
> > take appropriate action.  In some languages there is a function to
return
> > the actual line number where the error occurred, and also the source
code
> > statement that caused the error.

> > Is this possible in VBA?  If so, can anyone give me some guidance or
> direct
> > me to a source that will show how to do this?

> > If not, please direct me to some sources for developing good VBA error
> > handlers.

> > TIA.

> > Best Regards,
> > jmu

> > J. M. Underwood
> > Apollo Information Systems, Inc.
> > Houston, TX





Sat, 24 Jan 2004 20:09:20 GMT  
 Error Handler -- Getting Line Number of error

Ji, personaly the overhead of having line numbers scattered throughout
my code is not worth the effort just to get the line number of the
error in an error message.

In my view, returning the Module/Form/Class name, and the
Subroutine/Fuuunction/Property name is sufficient.

Quote:
><DIV>I'd like to design a VBA error handler based on where an error =
>occurs, and=20
>take appropriate action.&nbsp; In some languages there is a function to =
>return=20
>the actual line number where the error occurred, and also the source =
>code=20
>statement that caused the error.<BR><BR>Is this possible in VBA?&nbsp; =
>If so,=20
>can anyone give me some guidance or direct me to a source that will show =
>how to=20
>do this?</DIV>

--------------
Progressive Data Solutions
http://www.pdsolutions.com.au
Home of VB Code Cutter - VB/VBA Code Library, Dev Tool with Free code formatting/indenting


Wed, 11 Feb 2004 07:58:35 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Error Handler - How to get line number where error occurred

2. Line Number In a VB Error Handler

3. Getting line numbers for runtime errors

4. Getting Line number for error trapping routine

5. Getting Line number for error trapping routine

6. ERROR HANDLERS RUNNING WITHOUT ERRORS

7. Error handling in an error handler?

8. error handler not capturing error??

9. error occurring within error handler

10. Access 97 Error Logging - Line Number

11. Returning the line number with the error message

12. Getting Error Number 50001

 

 
Powered by phpBB® Forum Software