Access JumpStart 2.0 | Blog

A Rapid Development Framework for Microsoft Access

Our Access application framework that Steve and I developed and use to build our apps is called Access JumpStart. It does not include vbWatchdog by default for those who buy our framework, but it contains code to work with vbWatchdog if the developer of the app has purchased a vbWatchdog license and installed vbWatchdog in the app.

In the AJS developer menu the developer can enable vbWatchdog which adds a compiler flag to include some routines to set a global error handler and use some of the useful information and features of the ErrEx object provided by vbWatchdog.

The AJS app will continue to work with or without vbWatchdog with the app being unaware of the difference, albeit without global error handling. But there are other features such as error logging to the Immediate window, a file, or a database table which are built in to the framework and can be used with or without vbWatchdog.

Here is the global error handler that gets run if vbWatchdog is installed:

Public Sub GlobalErrorTrap()
' Compiler constant
#If AJS_vbWinst Then
   ' Display error trap info in the immediate window if we're in development mode
   If AJSOpt.AJS_DevMode And AJSOpt.AJS_vbW_VBEprint Then
      Debug.Print "vbW: " & ErrEx.StateAsStr & " in " & ErrEx.SourceModule & "." & ErrEx.SourceProcedure & ": Line " & _
         ErrEx.SourceLineNumber & ", Error: " & ErrEx.Number & ", " & ErrEx.Description & ", VBA: " & ErrEx.SourceLineCode
   End If

   ' These are global module variables, simply being used here to pass info to other functions later.
   strModName = ErrEx.SourceModule
   strProcName = ErrEx.SourceProcedure
   lngErrNumber = ErrEx.Number
   strErrDesc = ErrEx.Description
   strErl = ErrEx.SourceLineNumber
   strSourceLineCode = ErrEx.SourceLineCode
   strErrSource = ErrEx.Source

   Select Case ErrEx.State
    
      Case OnErrorGoto0
         ' ---------------------------------------------------------------
         ' Unhandled errors
         ' ---------------------------------------------------------------
         If AJSOpt.AJS_DebugON Then    ' for Debug modes 1 or 2
            ErrEx.State = ErrEx.ShowErrorDialog
         Else
            RDI_GblErrHandler_M strModName, strProcName, , , True, lngErrNumber, strErrDesc, strErl, strSourceLineCode, strErrSource
            ErrEx.State = OnErrorResumeNext
         End If
                
      Case OnErrorGotoLabel
         ' ---------------------------------------------------------------
         ' Ignore locally handled errors, initially
         ' ---------------------------------------------------------------
         ' Save the vbWatchdog error info for potential later display by AJS.gblerrhandler call
         RDI_GblErrStore_M strModName, strProcName, lngErrNumber, strErrDesc, strErl, strSourceLineCode, strErrSource
         If AJSOpt.AJS_DebugON = 2 Then    ' for Debug mode 2
            ErrEx.State = ErrEx.ShowErrorDialog
         Else
            ' Ignore the locally handled error
         End If

      Case OnErrorPropagate
         ' ---------------------------------------------------------------
         ' Ignore locally handled errors
         ' (handled by a previous routine in the call stack)
         ' ---------------------------------------------------------------
         RDI_GblErrStore_M strModName, strProcName, lngErrNumber, strErrDesc, strErl, strSourceLineCode, strErrSource
         If AJSOpt.AJS_DebugON = 2 Then    ' for Debug mode 2
            ErrEx.State = ErrEx.ShowErrorDialog
         End If
         
      Case OnErrorResumeNext
         ' ---------------------------------------------------------------
         ' Ignore errors when On Error Resume Next is set
         ' ---------------------------------------------------------------
         ' Save the vbWatchdog error info for potential later display by AJS.gblerrhandler call
         RDI_GblErrStore_M strModName, strProcName, lngErrNumber, strErrDesc, strErl, strSourceLineCode, strErrSource
            
      Case CalledByLocalHandler
         'NOTE: unused by AJS, but may be used by Developer for application code
         ' ---------------------------------------------------------------
         ' ErrEx.CallGlobalErrorHandler was called
         '   This is a special case for when local error handling was in use
         '   but the local error handler has not dealt with the error and
         '   so has passed it on to the global error handler
         ' ---------------------------------------------------------------
         'LogErrorToTable
         ' ---------------------------------------------------------------
         ' Since this global error handler routine is for 'release', not
         '   'development', we don't really want to end abruptly here.
         ' So instead, we set ErrEx.Status = CalledByLocalHandler
         '   which ensures we resume after the CallGlobalErrorHandler
         '   line - where cleanup code can then be done
         ' ---------------------------------------------------------------
         If AJSOpt.AJS_DebugON Then    ' for Debug modes 1 or 2
            ErrEx.State = ErrEx.ShowErrorDialog
         Else
            RDI_GblErrHandler_M strModName, strProcName   ' use the details previously stored via RDI_GblErrStore_M call
            ErrEx.State = CalledByLocalHandler
         End If
            
   End Select

#End If
End Sub

There are a few settings for debugging which change behaviors of how different types of errors are handled.

In dev mode we want to get the enhanced debug box offered by vbWatchdog by default. For production, that is turned off and only a simpler, but still enhanced message box is used for errors that the customer can copy and paste from the dialog.

You can purchase Access JumpStart (a product of Halder Consulting, Inc.) here: Add AJS to your shopping cart

You can purchase a license for vbWatchdog from Everything Access (not affiliated with Halder Consulting or Access JumpStart) here: vbWatchdog v4 Purchase information