Jump: Search:

Total Visual SourceBook

Total Visual SourceBook CD and Printed Manual

Microsoft Access 2007/2010 Version
is Shipping!

New features in Total Visual SourceBook for Access, Office 2007 and VB6

Supports Access/Office 2010 (32 bit), 2007, 2003, 2002, 2000, and
Visual Basic 6.0!

Also available for:
Access 97/95


View all FMS products for Microsoft AccessAll Our Microsoft Access Products

SourceBook Info:

Why SourceBook?

 

"The code is exactly how I would like to write code and the algorithms used are very efficient and well-documented."

Van T. Dinh, Microsoft MVP

 

 

 

 

 
Royalty free source code library modules for Microsoft Access, VB6, VBA, OfficeRoyalty free source code library modules for Microsoft Access, VB6, VBA, OfficeVBA and VB6 Source Code Library Download the free trial version of Total Visual SourceBook for Microsoft Access, Office, VB6 and VBA
Category: Microsoft Visual Basic 6 : Application Techniques
Description: VB Application Techniques

Class: CErrHandler

Class that provides a standardized error handling mechanism to trap errors, track the location and type of the errors, and to allow the programmer to take appropriate response

Procedure Name

Type

Description

(Declarations) Declarations Declarations and private variables for the CErrHandler class
AppTitle Property Gets the application title (defaults to the value of your application's app.title property)
CurrentOperation Property Sets the current operation
Destination Property Gets the destination
DisplayMsgOnError Property Sets whether to display a messagebox when an error is handled
ErrorDescription Property Gets the description of the error that caused the error handler to be triggered
ErrorLine Property Gets the line number of the procedure that caused the error when the error handler was triggered
ErrorNumber Property Gets the error code that caused the error when the error handler is triggered
IncludeExpandedInfo Property Gets the value of IncludeExpandedInfo
ProcName Property Gets the name of the procedure containing the error which caused the error handler to be triggered.
TraceExecution Property Starts or stops tracing execution of the program. If this property is true, a log file is maintained which tracks each procedure which is logged by the Push method. Even if no error occurs in the procedure, an entry is written. This information can be useful to trace the order in which procedures are called in your application. By default the information is stored in a file named "trace.log" in your application's directory.
AppSpecificErrHandler Private Custom error handler stub subroutine. The recommended way to use the CErrHandler class is to have it raise events into your program. You can receive the BeforeHandlerCalled and AfterHandlerCalled events. There you can provide specific functionality for your program, such as displaying a custom error message form, or closing the program cleanly. The advantage to using the events is that the CErrHandler object can be completely generic. All custom app-specific logic is contained in your program, not in the class itself. If you cannot use the events however, because you are declaring the error handler object variable in a standard module, which cannot receive events, you can customize this procedure to provide app-specific error-handling logic. All app-specific logic should be confined to this procedure. That way when you incorporate the CErrHandler class into your application, this is the only part of the code that will need to be modified.
Class_Initialize Initialize Set initial values to defaults which may be overridden with property settings
Class_Terminate Terminate Close trace log if opened, and check to be sure that all Push calls are balanced by Pop calls. If you raise an assertion at this point, double-check your code to see that you are calling the error handler correctly.
ClearLog Method Clear the error log (or table depending on the setting of the Destination property). If Destination is a string property indicating a DOS text file, this function simply deletes the file. If Destination is a Recordset object, this method deletes all rows from the recordset.
GetLastErr Private This method is called to get the last error that occurred. We increment the pointer as one of the last things done in Push() in order to add the next procedure to the next item available in the stack array. However, if an error occurred before we could add the next procedure to the stack, we need to go back to the previous item in the array to get the error that occurred.
HandleError Method
LogErrorToFile Private Logs the most recent error to a disk file. The name of the file is specified by setting the Destination property of the error handler object to a string containing the file name path
LogErrorToTable Private Logs the most recent error to a table. The table is specified by setting the Destination property of the error handler object to a recordset object which you create in your application
Pop Method Pops the current procedure name off the error handling stack. Normally this procedure is called when exiting a procedure normally when no error has occurred. It must be balanced by a call to the Push method when the procedure is first called.
Push Method Pushes the supplied procedure name onto the error handling stack. You must manually assign the name of the current procedure to the strProc argument. It must be balanced by a call to the Pop method which is called when the procedure exits normally.

Overview of Total Visual SourceBook

The source code in Total Visual SourceBook includes modules and classes for Microsoft Access, Visual Basic 6 (VB6), and Visual Basic for Applications (VBA) developers. Easily add this professionally written, tested, and documented royalty-free code into your applications to simplify your application development efforts.

Additional Resources

Feedback

Contact Us  l   Web questions: Webmaster   l   Copyright © FMS, Inc., Vienna, Virginia
Celebrating our 26th Year of Software Excellence