Name of currently running Sub/Function?

C

CyberDwarf

Hi,



Here's a weird one!

Is there a known way to determine the name of the currently running Sub or
Function in VBA code?

I'm trying to build a generic error-trapping funtion, to avoid writing
hundreds of

ON ERROR GOTO

blocks, with different parameter values.

I've been looking at ways to use the Windows API with AddressOf, etc, but I
can't see how I can get this to work...



Any hints and suggestions welcomed

TIA



Steve
 
R

Rick Brandt

CyberDwarf said:
Hi,



Here's a weird one!

Is there a known way to determine the name of the currently running
Sub or Function in VBA code?

I'm trying to build a generic error-trapping funtion, to avoid writing
hundreds of

ON ERROR GOTO

blocks, with different parameter values.

I've been looking at ways to use the Windows API with AddressOf, etc,
but I can't see how I can get this to work...



Any hints and suggestions welcomed

There is no way to do this in Access other than to code it into each error
handler. My generic handler takes a string argument where I supply the name
of the function or sub so that the handler can use it for logging and
messages. You have to create the handler "structure" per procedure anyway
so while creating that it is not such a big deal to type the name of the
procedure at the same time.
 
C

CyberDwarf

Hi Rick

Thanks for the info.

My real problem is that I have inherited an app with 3500
subs/functions!!!!!!

Doh!

Ah well

Steve
 
D

Douglas J. Steele

Take a look at MZ Tools (http://www.mztools.com)

This free add-in can automatically insert error handling into each routine,
and it's capable of determining the name of the current sub/function when it
does that.
 

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