IN THE SPOTLIGHT: MDE to MDB Conversion Service
(also supports: ACCDE to ACCDB, ADE to ADP, etc)
IN THE SPOTLIGHT: Access Database Repair Service
An in-depth repair service for corrupt Microsoft Access files
IN THE SPOTLIGHT: vbWatchdog
VBA error handling just got easier...
" vbWatchdog is off the chart. It solves a long standing problem of how to consolidate error handling into one global location and avoid repetitious code within applications. "
- Joe Anderson,
Microsoft Access MVP
Meet Shady, the vbWatchdog mascot watching over your VBA code →
(courtesy of Crystal Long, Microsoft Access MVP)
IN THE SPOTLIGHT: vbMAPI
An Outlook / MAPI code library for VBA, .NET and C# projects
Get emails out to your customers reliably, and without hassle, every single time.
Use vbMAPI alongside Microsoft Outlook to add professional emailing capabilities to your projects.
IN THE SPOTLIGHT: Code Protector
Standard compilation to MDE/ACCDE format is flawed and reversible.
The VariablesInspector object gives you the unique ability in your global error handler to inspect the values of all local variables in the procedure that caused the exception.
Not only that, but you can also traverse the stack and report the values of all local variables in all procedures that led up to the procedure of error being called!
We expose the VariablesInspector class object at two points - ErrEx.VariablesInspector and ErrEx.CallStack.VariablesInspector.
Works with all editions of VBA6, even if running a compiled MDE or with the Access runtime.
Unfortunately this feature is not available for the SimplyVB6 edition of this product. VBA only.
Requires DISTRIBUTABLE EDITION to be purchased for reading or displaying the variable values.
To simply add a 'Show Variables' button to our Vista-style error dialog, just set the property ErrEx.DialogOptions.VariablesButtonEnabled to True and you will get a cool button added to your error dialog:
The rest of this page is for those that want to implement this functionality into their own custom error dialog forms or for logging purposes.
In it's simplest form, you can call the VariablesInspector.DumpAll method which returns a String value containing a simple dump of all variable names, data types and current values:
Public Sub MyGlobalErrorHandler() MsgBox ErrEx.VariablesInspector.DumpAll End Sub
This would produce something like this:
You can also traverse the call stack and for each procedure in the stack, dump all variables as a string:
Public Sub MyGlobalErrorHandler() Dim strDump As String Do ' Header text - module name + procedure name strDump = strDump & " >> " & ErrEx.CallStack.ModuleName & "." & ErrEx.CallStack.ProcedureName & vbCrLf & vbCrLf ' Dump the variable details from this procedure... strDump = strDump & ErrEx.CallStack.VariablesInspector.DumpAll & vbCrLf Loop While ErrEx.CallStack.NextLevel MsgBox strDump End Sub
Which might produce:
Taking this a step further - perhaps you want to customize the "dump" into your own format. This is how:
Start by calling the .FirstVar method which ensures we've got a reference to the first variable. Next, loop through the variables using the .NextVar mthod but checking first that we haven't reached the end of the variables list using the .IsEnd method.
Whilst iterating through the variables, use the following read-only properties to identify the variable:
.Name | string expression of the variable name |
.TypeDesc | string expression of the variable data type (e.g. 'DAO.Database', 'Long', 'String' etc) |
.Value | variant copy of the variable value (no matter what data type, all values are coerced into this Variant property) |
.ValueDesc | string expression of the value. String data types have the double-quotation marks added, 'Object' types are either 'Nothing' or '{Object}' etc. It is advised to use .ValueDesc rather than .Value under normal circumstances. |
.Scope | enumeration to determine what type of variable this is - One of ParameterVariable, LocalVariable, StaticVariable or ModuleVariable |
.ScopeDesc | string expression of the .Scope property. One of "PARAM", "LOCAL", "STATIC" or "MODULE" |
An example:
With ErrEx.VariablesInspector .FirstVar While .IsEnd = False strDump = strDump & "(" & .ScopeDesc & ") " & .Name & " As " & .TypeDesc & " = " & .ValueDesc & vbCrLf .NextVar Wend MsgBox strDump End With
Similarly, this technique can be used on the ErrEx.CallStack.VariablesInspector instead whilst traversing through the call stack.
Check out the Sample.mdb for an example of using .DumpAll method and also for the advanced method of accessing the variables values (the Developer Access Form example in particular).
iTech Masters | VAT: GB202994606 | Terms | Sitemap | Newsletter