Getting function and procedure names using VBA 
Author Message
 Getting function and procedure names using VBA

Hi,

Is it possible to dynamically get the name of a function or procedure that
is currently running. We want to be able to write the name of the function
to an ErrorLog table when an error occurs.

All the books we have looked at say that it isn't possible in VBA (Access
2000)

Thanks
Mike



Mon, 28 Jun 2004 07:38:36 GMT  
 Getting function and procedure names using VBA
Hi Mike,
I'm not sure whether this is possible
or not however, your error handling could
take care of this.

I use a free add-in that generates a basic error
handler. it looks like this:

    MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure cboClients_Click of Form
frmViewPmnts"

You could simply write that message to a table.
You could of course write this yourself.

If you want the add-in, it's at:
http://www.mztools.com/

Only for 2000 and above though.

HTH
Dan Artuso, MVP

Quote:

> Hi,

> Is it possible to dynamically get the name of a function or procedure that
> is currently running. We want to be able to write the name of the function
> to an ErrorLog table when an error occurs.

> All the books we have looked at say that it isn't possible in VBA (Access
> 2000)

> Thanks
> Mike



Mon, 28 Jun 2004 08:58:44 GMT  
 Getting function and procedure names using VBA
I *think* one of work-around is to declare a Local String constant in each
Procedure like

CONST strProcName As String = "{TheProcedureName}"

and use it when needed.

HTH
Van T. Dinh


Quote:
> Hi,

> Is it possible to dynamically get the name of a function or procedure that
> is currently running. We want to be able to write the name of the function
> to an ErrorLog table when an error occurs.

> All the books we have looked at say that it isn't possible in VBA (Access
> 2000)

> Thanks
> Mike



Mon, 28 Jun 2004 08:34:46 GMT  
 Getting function and procedure names using VBA
Thanks Dan,

Will give it a try and see if that solves my problem.

Cheers
Mike

Quote:
> Hi Mike,
> I'm not sure whether this is possible
> or not however, your error handling could
> take care of this.

> I use a free add-in that generates a basic error
> handler. it looks like this:

>     MsgBox "Error " & Err.Number & " (" & Err.Description & ") in

procedure cboClients_Click of Form
Quote:
> frmViewPmnts"

> You could simply write that message to a table.
> You could of course write this yourself.

> If you want the add-in, it's at:
> http://www.mztools.com/

> Only for 2000 and above though.

> HTH
> Dan Artuso, MVP


> > Hi,

> > Is it possible to dynamically get the name of a function or procedure
that
> > is currently running. We want to be able to write the name of the
function
> > to an ErrorLog table when an error occurs.

> > All the books we have looked at say that it isn't possible in VBA
(Access
> > 2000)

> > Thanks
> > Mike



Mon, 28 Jun 2004 11:16:17 GMT  
 Getting function and procedure names using VBA
The books are right. VBA doesn't provide this info.

The proc name must be hard-coded, but there's an example of
how to log it in article:
    Error Handling in VBA
at:
    http://users.bigpond.net.au/abrowne1/ser-23a.html

Quote:

> Is it possible to dynamically get the name of a function or procedure that
> is currently running. We want to be able to write the name of the function
> to an ErrorLog table when an error occurs.

> All the books we have looked at say that it isn't possible in VBA (Access
> 2000)

--
Allen Browne, Microsoft Access MVP
Perth, Western Australia.
Tips for Access users at:
    http://users.bigpond.net.au/abrowne1/


Mon, 28 Jun 2004 23:42:10 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Getting the list of Excel Sheet Names using VBA

2. Getting the User Group name using Current User Function

3. Getting the function's name during runtime while running in the scope of the function

4. Getting name of current procedure

5. Getting active procedure's name

6. Executing Function using String Containing Function Name

7. Collection of VBA procedure names?

8. Exec. Word VBA Function From Access using VBA

9. How Do I Extract a Function/Procedure Name

10. How to get function/sub procedure name

11. Q: printing procedure/function/sub name

12. passing Procedure/Function-name as an argument

 

 
Powered by phpBB® Forum Software