Procedure Name

S

Simon Morley

Afternoon All,

I have 20 odd forms, with lord only knows how many procedures, and I'm
trying to write a 'one-function-does-all' error handling procedure. What
I'm planning to do is have a popup message that displays the details of the
error whilst logging those details in a table somewhere and then simply kill
the procedure when the error has not been handled specifically.

There are two bits of info however that I can't find: firstly, I'd like to
be able to record the procedure name that caused the error, e.g.
Retrieve_Click, and the line number on which the error was caused (so when a
user reports an error, I can immediately identify what caused it).

Also, I am planning on cut 'n pasting the error code I write into each
procedure however I'd ideally like to write a proc that would override the
standard Debug/End dialog that VBA uses with my user friendly message box (I
don't want the user to be able to do anything other than report the error
and kill the proc that caused it). I would then need the full proc name,
i.e. Forms!frmMain.Retrieve_Click for my log to be of any use.

Any and all ideas on the above gratefully received.

Simon
 
G

Guest

A couple of things to consider:

1) VB does no give you access tot he execution stack and the ErrObject.Source property points to the DLL not the Procedure. I think that this is next to useless information.

2) Error handles can be nested to many levels (I am unsure of any limit). If you raise an error in an error handler, control shifts to the next level up in the nesting. If there is not "next level up", then VB generate the ugly standard message box.

3) Events alwasy start a new nesting sequence -- thus if you raise and error in the Error Handler of an Event, you get the ugle standard message box.

So what I do is the following:

a) create a project global constant in a BAS module

Public Const gksProjacetName as string = "VictorsNiftyProject"

b) in each Class module or Form, I create a module constant

Private mksClassName as string = glsProjectName & ".MyForm123"

c) in each Procedure in which i want an error handler the structure is

Private Sum MySub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top