Returning sub or function name within a specific sub or function 
Author Message
 Returning sub or function name within a specific sub or function

Hi

Is it possible to obtain the name of the sub or function that is executing
to be displayed in a message box when an error occurs

For instance:
If  Form_Load() caused the error the messagebox should show the error
number(err.number) , description (err.description) and the function
name(Form_Load) aswell.
the  err.source property only returns the name of the project, which is not
quite what i am looking for

Thanks
Nicolaas



Sat, 31 Aug 2002 03:00:00 GMT  
 Returning sub or function name within a specific sub or function
To see ur error messagebox

Go to tool/option/general......Error trapping......set to Break  on Unhandled
Error.

then run it.

hope this helps
regards,
afraz

Quote:

> Hi

> Is it possible to obtain the name of the sub or function that is executing
> to be displayed in a message box when an error occurs

> For instance:
> If  Form_Load() caused the error the messagebox should show the error
> number(err.number) , description (err.description) and the function
> name(Form_Load) aswell.
> the  err.source property only returns the name of the project, which is not
> quite what i am looking for

> Thanks
> Nicolaas



Sat, 31 Aug 2002 03:00:00 GMT  
 Returning sub or function name within a specific sub or function
No. The best you can do is use a string literal or constant:

Sub Form_Load()
Const PROC = "Form_Load"

    On Error Goto ErrorHandler
...
Exit Sub
ErrorHandler Err.Raise Err.Number, PROC, "Doh!"
End Sub

(this is not meant to illustrate good error reporting!)
--
RobSmith

: Is it possible to obtain the name of the sub or function that is executing
: to be displayed in a message box when an error occurs



Sat, 31 Aug 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Calling a sub or function using a variable through another sub or function

2. Local function/sub inside function/sub

3. Retrieve name of Function, Sub, Class, Property etc from within that item during runtime

4. Automatic capitalization of variable names, type names, subs and functions

5. Retrieve name of current sub/function and name of current module

6. End a Sub from within a Function

7. return more than one Variable from a Sub/Function

8. Need Function that Returns Files in all Sub-Directories

9. Obtaining Current Sub/Function Name

10. How to get function/sub procedure name

11. Function/Sub Name

12. (Q) Getting current Sub/Function name (or Object Browser functionality)

 

 
Powered by phpBB® Forum Software