Find Where A Sub / Function was called from?

ian_w

Registered User.
Local time
Today, 00:30
Joined
Jun 13, 2006
Messages
64
When a sub or function is called is it possible to record where it was called from?

Access 97 btw.

Thanks
 
in code, you can search for a sub - and see where it may have been called from

you can also write code that will create a call stack, so you can identify (in the event of an error, say) the calling activity - but i dont think otherwise you can state for certain how a call was made.

if it is just one function, you could always add an argument that specfically identifies the caller of the sub.
 
We have a function thats used in numerous different forms to collect some data, just wanted to try and capture where it was being called from so we can do some error recording if it fails (as you say).

Not a desperate requirement though, just something that would of been nice.
 
as i say, append an argument to each routine that calls the sub - then just amend any calls that may produce this, to add some sutiable text in the optional parameter.

Code:
function myfunc(args1, arg2, optional calledfrom as string)
...
...
...

error_handler:
if not ismissing(calledfrom) then
      msgbox("error: " & err & "  Desc: " & err.description & vbcrlf & vbcrlf & _
           "function was called from " & calledfrom)
else
      msgbox("error: " & err & "  Desc: " & err.description & vbcrlf & vbcrlf & _
          "no details of calling source")
end function
 

Users who are viewing this thread

Back
Top Bottom