Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which SUB is calling this SUB

Tags:

vba

ms-access

Does anyone out there know how to do a stack trace in access-vba. I'm trying to do something like:

Public Sub a()   
    Call c    
End Sub    

Public Sub b()    
    Call c    
End Sub

Public Sub c()    
    Debug.Print "Which sub has called me ?"    
End Sub

What I want to do in Sub c is to show if that has been called by Sub a or Sub b without passing any arguments. In c I would simply show the stack but I have no idea if this is even possible in VBA - any thoughts ?

like image 794
Richard Spencer Avatar asked Jun 11 '13 07:06

Richard Spencer


People also ask

How do you call a sub procedure?

To call a Sub procedure from another procedure, type the name of the procedure and include values for any required arguments. The Call statement is not required, but if you use it, you must enclose any arguments in parentheses. Use a Sub procedure to organize other procedures so they are easier to understand and debug.

How do I run a sub in VBA?

You can run a Sub procedure in the VBA Editor by pressing F5 or from the menu bar Run. An end user can start a sub from a button on a worksheet or from the ribbon.

Can a sub call another sub?

You can call a Sub from another Sub or User-Defined Function in VBA by using the term “Call” with the name of the Sub, or simply putting the name of the Sub. If the Sub to be called contains an argument, you have to call the Sub with any value of that argument.


1 Answers

You can use Mztools Addins which has an option to view the procedure caller. Download Mztools

enter image description here

like image 194
Santosh Avatar answered Sep 26 '22 17:09

Santosh