Call Stack, who knew?? (1 Viewer)

NauticalGent

Ignore List Poster Boy
Local time
Today, 12:55
Joined
Apr 27, 2015
Messages
6,281
All the time I have wasted tracing through code when the ultimate short-cut was right there in front of me...
 

plog

Banishment Pending
Local time
Today, 11:55
Joined
May 11, 2011
Messages
11,611
How about a link or further explanation for those who follow and are in a similar situation?
 

jdraw

Super Moderator
Staff member
Local time
Today, 12:55
Joined
Jan 23, 2006
Messages
15,364
Lots of info if you google ms access vba callstack
 

isladogs

MVP / VIP
Local time
Today, 16:55
Joined
Jan 14, 2017
Messages
18,186
Hi
I've never used the call stack so would also be interested in knowing more.

I do know that UA member JonSmith has done a lot of work using this feature and has on several occasions written lengthy posts proclaiming its virtues. May be worth making contact with him
 

NauticalGent

Ignore List Poster Boy
Local time
Today, 12:55
Joined
Apr 27, 2015
Messages
6,281
Apologies for the delay, for some reason my computer at work does not like AWF. Frustrating...

In a nutshell, it makes debugging much, much easier - especially if your code calls Subs and Functions that are not in the current class module you are using.

When I first started using VBA, the vast majority of my code was confined to the form or report I was working on at the time. But as my skills improved and learned how to take advantage of my own UDF’s (thanks to the members of this Forum) it made debugging a bit of a challenge.

Using the Call Stack, I am able to trace back through the code via the Call Stack window. It places the current Sub I am in on the top. By clicking the other Subs in the window, it takes me to the point in the previous Subs where the other Subs were called. A real stream-lined process. Had I known about this feature before, it would have saved me hours of debugging.
 

isladogs

MVP / VIP
Local time
Today, 16:55
Joined
Jan 14, 2017
Messages
18,186
Thanks for posting the link DBG. That was the thread I was thinking of.
Despite JonSmith's very detailed code, I have to admit that I never got around to following it up as my own error handling routines have always been more than good enough for both my needs and my clients.

NG: Any chance of a simple example db that demonstrates its value?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 09:55
Joined
Oct 29, 2018
Messages
21,358
Thanks for posting the link DBG. That was the thread I was thinking of.
Despite JonSmith's very detailed code, I have to admit that I never got around to following it up as my own error handling routines have always been more than good enough for both my needs and my clients.

NG: Any chance of a simple example db that demonstrates its value?
Hi Colin. Based on NG's description from his last post, I get the impression he's merely talking about hitting Ctrl+L while in debug mode.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 16:55
Joined
Jul 9, 2003
Messages
16,244
my own error handling routines have always been more than good enough for both my needs and my clients.

I never used to worry too much about putting error checking in my functions. However I had the job of building a a runtime application which ran over Citrix, and it crashed, and crashed, and crashed, and I had to go through it all and put error checking code in it! It took forever, and it was the most thankless task I've ever done!

Now, I have a function stub which already has the error checking code in it. I just paste the function stub into my module. Quick simple easy. I know that if I ever get asked to Change the application to a run-time application then I'm ahead of the game!
 

isladogs

MVP / VIP
Local time
Today, 16:55
Joined
Jan 14, 2017
Messages
18,186
I introduced comprehensive error handling in every routine in my very large schools databases (FE approx 150MB). I did so because I couldn't rely on my clients to pass on detailed & accurate error information and so I couldn't fix issues unless I could replicate them

My error logging routine records all the details of each error - error number/description, exact location where it occurs, who was affected, workstation info, screen resolution, Access version & bitness, OS & bitness, app version etc ...
All of that info is then sent 'silently' by email to me (by agreement with the clients) without the user needing to do anything

The process took a very long time to setup (and I often felt like giving up!) & for the first few weeks after implementation I got a lot of automated emails. However there were relatively few errors involved (repeatedly) and allowed me to fix the bugs quickly
After a couple of months almost all the errors were fixed & I haven't received an error logging email for well over a year. I call that success!

Since then I now build in this code as I develop many of my new apps
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 16:55
Joined
Jul 9, 2003
Messages
16,244
I haven't received an error logging email for well over a year. I call that success!


That's Impressive!
I think that's partly a problem with MS Access, not a problem actually, but the fact that is so good, and once you've got it right it rarely causes any problems...

The only problem I can recall having which I never solved, in the sense that I never found out what caused it, was having a corrupt record in a table. The customer reported the problem, and I eventually located the corrupted record, then removed it, which to my vague recollection wasn't an easy process to do, removing a corrupt record, or it might have been the finding of it that record... I know it wasn't straightforward. The only thing I could think of that caused the corruption was somebody switching the PC off with MS Access running. I explain my suspicions about the PC being turned off and I've never had another issue with it. Now where's that big piece of wood?

So I think what I'm saying is I've never gone to any great trouble with error checking, just having the ability for each function to report its own name, and the module, or form it's within. I don't take it as far as you obviously have done! Mind you it sounds like the right thing to do especially if you've got a runtime app!
 

isladogs

MVP / VIP
Local time
Today, 16:55
Joined
Jan 14, 2017
Messages
18,186
The last error logging email I received was from someone who had downloaded the DEMO version of an app from my website. That surprised me. I emailed back but got no reply

Anyway the point I was really making was that I haven't seen any benefit in using call stack as I have my own system. But I'd be happy to be persuaded of its merits. As previously mentioned, Jon Smith at UA had some impressive code based on this.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 11:55
Joined
Feb 28, 2001
Messages
26,999
After doing a bit of research, I verified that you can use CTRL/L to display the call frame list on the stack. Which is no "duh" because that was mentioned in this thread. I also noted that there is general agreement in many external articles that without playing a "roll your own DLL" type of game, there is no programmatic way to actually see what is on the stack. I.e. the Access GUI can show you but you can't easily do a VBA-based examination. This is because among other things, the stack usage is not constant and you cannot see the hardware registers - including the user-mode stack pointer.

From one call to the next, the number of items pushed onto the stack is dependent on the local declarations in the subroutine. The amount of space available to the stack is fairly large, but it is hard to say exactly how much stack space you do have. Fortunately, unless you are writing some pretty ugly recursive code, you are unlikely to get a "stack overlaps heap" message - which is quite fatal if you get it.

In the worst code I ever wrote, I think the deepest I've ever seen the stack using the menu to "show call stack" was about a half-dozen layers deep counting the starting Event routine at the bottom of the stack and having several shared formatting routines and computational assistance routines in the stack frame list.

The ability to click on a particular frame so you can see it is a really great debugging tool. And it should be noted that if you do that (i.e. switch code windows to the point where a call occurred), that routine's locally-declared variables and any public variables from a general module still show you their values if you hover the mouse over them - even though the executing code is not in that context at the moment.

I have written some recursive code and I can report that using the "Show Call Frames" option to visit each frame lets you see the correct values for that frame even though the call is recursive and another instantiation of it is elsewhere in the same call frame list.
 

NauticalGent

Ignore List Poster Boy
Local time
Today, 12:55
Joined
Apr 27, 2015
Messages
6,281
Hi Colin. Based on NG's description from his last post, I get the impression he's merely talking about hitting Ctrl+L while in debug mode.

Exactly. Really cuts down on my Debug time becuase it lets me “walk backwards” while I am trouble-shooting”. My coding skills are not what the should be so what most of you get done right the first time takes a few attempts for me! Getting better though, if I do say so myself...

The ability to click on a particular frame so you can see it is a really great debugging tool. And it should be noted that if you do that (i.e. switch code windows to the point where a call occurred), that routine's locally-declared variables and any public variables from a general module still show you their values if you hover the mouse over them - even though the executing code is not in that context at the moment.

Doc nails it. What I had to do with a #2 pencil and a notepad can now be done on the fly. I can even make my changes and re-run the code from that point - a real time saver.

Funny thing is, it has always been there an two of the books I have bought talk extensively on how to use it but it was too “busy” to take the time to read and understand it. Life is tough, tougher if you’re stupid...
 

Users who are viewing this thread

Top Bottom