[AccessD] MZ Tools

John Colby jwcolby at gmail.com
Wed Jan 11 15:23:25 CST 2023

I use MZ Tools to build a consistent error handler in any function that
needs one.

Function ShowErrHandler()

    On Error GoTo ShowErrHandler_Error

    On Error GoTo 0
    Exit Function

Dim strErrMsg As String
    Select Case Err
    Case 0      'insert Errors you wish to ignore here
        Resume Next
    Case Else   'All other errors will trap
        strErrMsg = "Error " & Err.Number & " (" & Err.Description & ") in
procedure TestImport.Module1.ShowErrHandler, line " & Erl & "."
#If boolELE = 1 Then
        WriteErrorLog strErrMsg
#End If
        assDebugPrint strErrMsg
        Resume Exit_ShowErrHandler
    End Select
    Resume Exit_ShowErrHandler
End Function

I would love to do a thread about how each of us uses the snippets thingie
in MZ Tools.  I don't use the snippets mostly because I just never figured
out how.  MZ Tools already has a handful of snippets already assigned to
their toolbar and I figured out how to modify the one that builds the error
code and that is what you see above.

So what snippits do you guys use?  How are snippits created?  Linked to
hotkeys?  If anyone has a link to documentation on "how to" insert that in
the thread.

My error handler is nothing special except that I build out a case in the
error handler section.  I do specific things related to processing errors.

#If boolELE = 1 Then
        WriteErrorLog strErrMsg
#End If

Allows me to use a compiler directive to turn on or off (compile in or out)
a call to an error logger.  Most probabvly do, but for those who don't...

In the editor - click tools then select the properties and a form opens
which allows us to set a global (to the entire project) conditional
compilation arguments.  These compiler constants  will affect all code
throughout the project.


OTOH you can also do compiler constants that are only good inside the
module in which it is defined.

Option Explicit
#Const DebugMode = 1

Public Sub assDebugPrint(ByVal vstrMsg As String, Optional boolPrint As
Boolean = False)
#If DebugPrint Then
  If boolPrint = True Then Debug.Print vstrMsg
#End If
End Sub

This allows me to turn on and off debug printing the errors in the debug

Soo.... that is all I do with snippits.  What do you do and how do you do
John W. Colby
Colby Consulting

More information about the AccessD mailing list