How to Pass Line Number to Error Handler in MZ Tools

mlcktmguy
mlcktmguy used Ask the Experts™
on
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

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
Top Expert 2007

Commented:
User the ERL function

... error occurs

Error trapping code
Debug.Print erl
Database Architect / Application Developer
Top Expert 2007
Commented:
APP_AutoExec_Error:
    MsgBox "An unexpected error has occured" & vbCrLf & vbCrLf & _
     "Error Information --------------------" & vbCrLf & _
     "Error Number: " & Err.Number & vbCrLf & _
     "Description: " & Err.Description & vbCrLf & vbCrLf & _
     "Code Fx: " & sFx & vbCrLf & vbCrLf & _
    "Line Number: " & Erl & vbCrLf & vbCrLf & _
     "Steps to take:" & vbCrLf & vbCrLf & _
     "1) Take a screen shot of this error message and email it to the Database Administrator, with a brief explanation of what lead up to the error." & vbCrLf & vbCrLf & _
     "2) Close then reopen the database, then retry the operation. If the error continues, notify the database administrator immediately." _
     , 48, "APP_AutoExec"
    Resume APP_AutoExec_Exit
Jim Dettman (EE MVE)President / Owner
Most Valuable Expert 2017
Most Valuable Expert 2012

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

Jim.
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

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

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

ERL
Jim Dettman (EE MVE)President / Owner
Most Valuable Expert 2017
Most Valuable Expert 2012

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
Top Expert 2007

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

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial