How to Pass Line Number to Error Handler in MZ Tools

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?
LVL 1
mlcktmguyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
User the ERL function

... error occurs

Error trapping code
Debug.Print erl
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
Just a side note; it's an un-documented function and the full reference is VBA.erl

Jim.
 Acronis Global Cyber Summit 2019 in Miami

The Acronis Global Cyber Summit 2019 will be held at the Fontainebleau Miami Beach Resort on October 13–16, 2019, and it promises to be the must-attend event for IT infrastructure managers, CIOs, service providers, value-added resellers, ISVs, and developers.

mlcktmguyAuthor Commented:
Thanks
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
Jim ... undocumented ?
I typed erl into the VBA immediate window, hit F1 and ...

ERL
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
yes, the err object is, but never the VBA.ERL call to my knowledge.

Jim.
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
OOPS ... umm ... I saw err as ERL ... lol. My bad
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.