Solved how do I log my database event sequence? (1 Viewer)

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 07:21
Joined
Feb 28, 2001
Messages
27,131
In theory you could try to figure out which line of code is executing and from that, back-track to the SUB declaration for the event - but the overhead of such an action would be prohibitively expensive. Not to mention that it would involve self-referential code, which is a major no-no in any serious programming design. Nor am I sure of exactly how you might do that. But VBA knows which line it is because the debugger can show the line that failed.
 

MikeT1941

Member
Local time
Today, 13:21
Joined
Nov 18, 2020
Messages
46
Real shame you can not use something like Parent.Name.Event.Name for that debug.print statement :(
Gasman
very sorry- don't know why you got left off my thanks. After all- you said it first. Surely if I know the sequence of the VB code routines, then all I need is the times when the SQL kicks in e.g. queries? Or am I missing something/everything?
 

MikeT1941

Member
Local time
Today, 13:21
Joined
Nov 18, 2020
Messages
46
Doc
I'm not saying the code is broken- just enquiring about flicker, but certainly reducing file size has a lot to do with it. I observe that a large file size can appear twice with up to a 1 second gap, whilst reducing the file size almost eliminates the second showing- may eliminate it completely
 

jdraw

Super Moderator
Staff member
Local time
Today, 08:21
Joined
Jan 23, 2006
Messages
15,379
Glad the info was useful. My routine saves Forms, Subs, Functions to text, then parses the code and builds Insert Lines. I'm sure what gets put into the Debug.Print can be adjusted as needed (or parameterized).

Here is some of the code to add the Debug.Print to the Private Sub or Private Function in Form events.
Code:
  Open FileOutname For Output As #WriteFile

80        Do Until EOF(1)                       'do until input has been read in full
90            i = i + 1
100           Line Input #iFile, strTextLine    'read a line of input
        
110           If strTextLine Like "*Private Sub *" Then 'may need more criteria

120               SCNT = SCNT + 1                       'increment proc count
130               sHoldProcName = "   " & Mid(strTextLine, InStrRev(strTextLine, "Private Sub ") + 12)
140               strTextLine = strTextLine & vbCrLf & "Debug.print   Me.Name & """ _
                  & sHoldProcName & """    '" & Now & " ---modified code DebugFlow"    '---JED
150           End If

160           If strTextLine Like "*Private Function *" Then 'may  need more outbuf  criteria
170               SCNT = SCNT + 1
180               sHoldProcName = Mid(strTextLine, InStrRev(strTextLine, "Private Function ") + 17)
190               strTextLine = strTextLine & vbCrLf & "Debug.print "" & Me.Name & """ _
                 & sHoldProcName & """   '" & Now & " ---modified code DebugFlow"   '---JED
200           End If

210           outbuf = strTextLine

It was a work in progress to help someone who inherited a database and did not understand the "logic/flow".

In other cases, I have used a global variable gDebugShow (boolean) to invoke some display code.

eg. If gDebugShow then
....debug.print various info
end if

Good luck with your project.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 07:21
Joined
Feb 28, 2001
Messages
27,131
"Flicker" is one of those bug-a-boos that is hard to fathom sometimes. It comes from a .Repaint that is too close to another event (time-wise) that also involves a .Repaint - OR an event that NATURALLY causes a repaint, as for example a record navigation. It may also seem to flicker if you have a lot of data on the form (i.e. more data than background) and you do a .Requery or otherwise try to refresh the screen (i.e. .Refresh). This is something that is DEFINITELY sensitive to how much data you are showing. Of these, .Repaint is worst, then .Requery, then .Refresh (in terms of how much work is done).

Sometimes - certainly not ALL of the time - a DoEvents helps with excessive flicker. Finding the best place to do that, though, is a problem on its own.
 

Users who are viewing this thread

Top Bottom