Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding the Current Module / Subroutine Name

Status
Not open for further replies.

nevets2001uk

IS-IT--Management
Jun 26, 2002
609
GB
I am adding a form of error logging to my program as I will soon be relesing it as an alpha version around my company. I was wondering if there was a variable that holds the name of the modules / subroutine currently being executed.

For example if I had a sub called...

Private Sub Cmd_OK_Click()

How can I find this name instead of having to type it into my error string?

Any comments / suggestions about error logging for programs would also be appreciated.

Thanks,
Steve
 
There is no way of knowing what module you are in.

I suggest instead doing this...

At the start of your Module. Set I private to the name. so For example.
[tt]
Option Explicit
Private Const m_ModuleName = "Form1."
[/tt]
Then in each Function put.
[tt]
Private Sub Command1_Click()
MyName = "Command1_Click"
[/tt]
Then when you call the error handler.
[tt]
ErrHandler:
Call GlobalErr m_ModuleName & MyName & err.Number & err.Description.
[/tt]
See the Useful stuff section in My FAQ for more on error handling.
faq222-1694

Craig

"I feel sorry for people who don't drink. When they wake up in the morning, that's as good as they're going to feel all day."
~Frank Sinatra
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top