Question

Would it be possible to see the CallStack in VBA for MS Access 2003? That is to say, would it be possible to see from what procedure or function another function was called?

Was it helpful?

Solution

There is no programmatic way in VBA to view the call stack that I know of. The usual solution to this problem is to use some structure to track calling of functions, but it always seems like a kludge to me, and really of use only when programming (not at runtime), in which case it seems to me that the VBE's built-in capability for seeing the call stack is sufficient.

And, BTW, I always put the call stack button on my VBE toolbar, since it's one of the most frequently used functions for me. I also add the compile button -- I think it's crazy that it's not on the toolbar by default because it encourages people to code without ever forcing a compile. Then again, Access 2000 didn't even use Option Explicit by default (supposedly for consistency with the other apps using the VBE -- in other words, dumb down Access in order to make it consistent with apps that aren't nearly as code-heavy).

But I digress...

OTHER TIPS

At runtime, View menu -> Call Stack (or press CTRL + L).

Eventually, add an optional parameter to your function, and pass the caller name that way. For forms, you can use Me.Name as the parameter.

Yes it's possible, BUT it's not quite usefull!

Private Declare Sub SetMode Lib "vba332.dll" Alias "EbSetMode" (ByVal lngMode As Long)
Private Declare Function GetCallStackCount Lib "vba332.dll" Alias "EbGetCallstackCount" (lngCount As Long) As Long
Private Declare Function GetCallStackFunction Lib "vba332.dll" Alias "EbGetCallstackFunction" (ByVal Lvl As Long, ByRef strBase As String, ByRef strModule As String, ByRef strFunction As String, ByRef Done As Long) As Long

Before use GetCallStackCount and GetCallStackFunction call SetMode(2), and after SetMode(1).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top