We help IT Professionals succeed at work.

How to Pass Line Number to Error Handler in MZ Tools

mlcktmguy
mlcktmguy asked
on
180 Views
Last Modified: 2017-03-24
I used MZ Tools to create and implement a standard error handling routine in my application.

The code I currently insert into a respective module by the MZ Tools error handler.  Looks like this:


'- - - - - - - - - - - - - - - - - - - - - - - - - - G E N E R A T E D  E R R O R  C O D E ----------------
                               If isDeveloper then
                               Else
                                 On Error GoTo $P[CODE_ELEMENT_NAME]_Error    
                               EndIf
'- - - - - - - - - - - - - - - - - - - - - - - - - - G E N E R A T E D  E R R O R  C O D E ----------------

$P[METHOD_BODY]

'- - - - - - - - - - - - - - - - - - - - - - - - - - G E N E R A T E D  E R R O R  C O D E ----------------
                               On Error GoTo 0
                               Exit $P[CODE_ELEMENT_KIND_KEYWORD]
                               $P[CODE_ELEMENT_NAME]_Error:
                               sysErrorHandler Err.Number, Err.Description, "$P[CODE_ELEMENT_NAME]", "$P[PARENT_CODE_ELEMENT_NAME]", "$P[CODE_ELEMENT_KIND_KEYWORD]"
'- - - - - - - - - - - - - - - - - - - - - - - - - - G E N E R A T E D  E R R O R  C O D E ----------------
'



I am getting an error code from a module.  My current error logic tells me the module and subroutine(or function) where the error occurred but not the line number

I can use MZ Tools to put line number on all of the statements.

My question is is:  How to I pull the line number of the line where the error occurred?
Comment
Watch Question

DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
CERTIFIED EXPERT
Top Expert 2007

Commented:
User the ERL function

... error occurs

Error trapping code
Debug.Print erl
Database Architect / Application Developer
CERTIFIED EXPERT
Top Expert 2007
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
Jim Dettman (EE MVE)President / Owner
CERTIFIED EXPERT
Fellow
Most Valuable Expert 2017

Commented:
Just a side note; it's an un-documented function and the full reference is VBA.erl

Jim.

Author

Commented:
Thanks
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
CERTIFIED EXPERT
Top Expert 2007

Commented:
Jim ... undocumented ?
I typed erl into the VBA immediate window, hit F1 and ...

ERL
Jim Dettman (EE MVE)President / Owner
CERTIFIED EXPERT
Fellow
Most Valuable Expert 2017

Commented:
yes, the err object is, but never the VBA.ERL call to my knowledge.

Jim.
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
CERTIFIED EXPERT
Top Expert 2007

Commented:
OOPS ... umm ... I saw err as ERL ... lol. My bad