You’d like to optimize your VBA code, but it’s almost impossible to tell how long Access is spending inside any one routine and it’s difficult to track which procedures are called by your code most often. You’d like some way to track which routines are called, in what order, and how much time each takes to run. Can you do this?
As outlined in the Solution in Recipe 7.2, you can create a code profiler using a stack data structure to keep track of the execution order and timing of the procedures in your application. Though the code involved is a bit more advanced than that in the Solution in Recipe 7.2, it’s not terribly difficult to create the profiler. Using it is simple, as all the work is wrapped up in a single module.