Dan Waters
dwaters at usinternet.com
Thu Jul 24 13:00:25 CDT 2008
Great! I'll give this a try. Dan -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Charlotte Foust Sent: Thursday, July 24, 2008 11:44 AM To: Access Developers discussion and problem solving Subject: Re: [AccessD] Call Stack in VBA? I wonder if he posted it on the L list? Anyhow, here's the code: ' Code starts - save as a Class module named clsStack '################################### Option Compare Database Option Explicit ' A Stack implemented as a Collection 'Example: ' Sub testStack() ' Dim stack As New clsStack ' Dim n As Integer ' Dim r As Variant ' stack.Push 1 ' stack.Push "One" ' stack.Push 2 ' stack.Push "Two" ' For n = 1 To 5 ' r = stack.Pop ' If IsNull(r) Then ' Debug.Print "Stack empty" ' Else ' Debug.Print r ' End If ' Next n ' Set stack = Nothing ' End Sub Dim modCollection As Collection Private Sub Class_Initialize() Set modCollection = New Collection End Sub Private Sub Class_Terminate() Set modCollection = Nothing End Sub Sub Push(vItem As Variant) If modCollection.Count = 0 Then modCollection.Add vItem Else modCollection.Add vItem, , , modCollection.Count End If End Sub Function Pop() As Variant If modCollection.Count = 0 Then Pop = Null Else Pop = modCollection(modCollection.Count) modCollection.Remove modCollection.Count End If End Function Charlotte -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Dan Waters Sent: Thursday, July 24, 2008 9:15 AM To: 'Access Developers discussion and problem solving' Subject: Re: [AccessD] Call Stack in VBA? Thanks Charlotte - I just checked the archives for clsStack, but no results came back. Do you have more information about what Lambert posted? Thanks, Dan -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Charlotte Foust Sent: Thursday, July 24, 2008 10:18 AM To: Access Developers discussion and problem solving Subject: Re: [AccessD] Call Stack in VBA? I don't know if you can get at the actual call stack, but you can use "push" methods to write a line to a collection, an xmlfile or even a straight text file and "pop" methods to remove the line after the call successfully executes. An error would result in the "pop" not being executed, giving you a list of steps that got you to the error. I used to do this years ago based on an article written for A97 (I think) that I adapted to my own uses. I created a CallStack class with push and pop methods, but it took a lot of work to pass the name of each routine into the stack since Access didn't give a simple method for retrieving the name of the procedure. I finally used a local constant, procName, in each routine and populated it when I built the routine. Actually, searching back through my archives, I find that Lambert posted a clsStack, which uses a collection, ages ago as well, so you might root through the archives for more. Charlotte Foust -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Arthur Fuller Sent: Thursday, July 24, 2008 7:47 AM To: Access Developers discussion and problem solving Subject: Re: [AccessD] Call Stack in VBA? What a great idea! I hope someone has your answer. You're right, it would be incredibly useful. On Thu, Jul 24, 2008 at 8:56 AM, Dan Waters <dwaters at usinternet.com> wrote: > Is there a way to use VBA to record the call stack? In my error > trapping routine, this would be incredibly helpful. > > Thanks! > Dan > -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com