How do I diagnose Access repeatedly crashing ? (1 Viewer)

GK in the UK

Registered User.
Local time
Today, 12:58
Joined
Dec 20, 2017
Messages
232
I have two main forms, functionally similar but sufficiently different to justify separate forms.
Each form opens a detail form on a double click event in a tree view control. The detail forms are also functionally similar.
So, two main forms, each of which displays a tree view control, and two detail forms.

Sometimes, Access crashes several times on the first open of the detail form from a cold start of Access. It quits, often two or three times, I restart Access each time, and on the third or more try the form opens and everything continues as normal.

I get this behaviour on both of the two main forms.

To try and figure out what is going on, I call an error logger immediately before the DoCmd.OpenForm line of the calling form. In the Open event of the detail form, I have a single line of code to call the same error logger. When it quits I get the log event saved to the table from the calling form but not the detail form. Does it follow that the issue is with the calling form ?

I've had this undiagnosed crashing before, with a different form. I never figured it out. The form was in development and I'd hoped that I would accidentally discover what the problem was, or accidentally fix it. I never did, and I rebuilt the form from scratch, pasted the code in and it's worked ever since.

Addendum: I just completely rebuilt one of the actual main forms. Started with a new form and put all new controls with matching names, no copying and pasting of any controls. Then, pasted the module code in from the 'old' main form, into the module for the 'new' form.

I just got the same quitting on the second double-click open of the detail form. So I seemed to have ruled out the detail forms. Access appears to be quitting, AFTER the call to the error logger (which writes a row to the table even when it quits) but possibly BEFORE the actual OpenForm command.

Obviously there is some common code in both main forms, and both detail forms. Both forms have the same tree view control.

Can't post the db. I'm using Access 2016 64-bit.

Code:
Private Sub tvw_TreeviewNodeDblClick(PK As Variant)
'On Error GoTo Err_Handler

'  Dim Level As Integer
'  Dim identifier As String
'  Dim frm As Access.Form
'  Dim msg As String
'  Dim strArgs As String
'  identifier = TVW.SelectedNodeIdentifier
'  Level = TVW.SelectedNodeLevel
'  PK = PK
 
  '   Set frm = Screen.ActiveForm
  '   msg = "This is a trapped event. You could do lots of things like open a detail form." & vbCrLf
  '   msg = msg & "You know the selected nodes PK: " & PK & vbCrLf
  '   msg = msg & "You know the tbl it came from based on the Identifier: " & identifier & vbCrLf
  '   msg = msg & "You know what level of the tree: " & Level & vbCrLf
  '   msg = msg & "If you have multiple treeview Forms on different forms, you know the form: " & frm.Name
  '   MsgBox msg
 
  ' OpenArgs passed through:
  ' (0) form caption
  ' (1) 'incl' means include unposted transactions
  ' (2) start period eg 202006
  ' (3) end period eg 202012

' 13th Sep still crashed after double clicking !

  'If Nz(PK, 0) <> fSetting("RetPlAc") Then
    ' no transactions are linked to the Retained Profit and Loss Account
    ' so there is no point in opening the form BUT we might want to
    ' allow this so we can edit the nominal record description ?
    
' see if we get an error log when we crash on double-click of the node
Call LogError(99, "testing 1 >" & gstrNominal & "<", Me.Name & ":tvw_TreeviewNodeDblClick", , False) ' YES logs even when crashes
    
    DoCmd.OpenForm (gstrNominal), DataMode:=acFormReadOnly      ' <<<<<< crashes on this line OR on open of the actual form
    
Call LogError(99, "testing 2 >" & gstrNominal & "<", Me.Name & ":tvw_TreeviewNodeDblClick", , False) ' NO does not log when crashes
    
'    ' 13th Sep try this to stop the intermittent crashing    ' NO still crashing
'    DoEvents

    ' 13th Sep, following does not appear when crashes, so problem is with frmNominal ?
    ' when working, this appears AFTER frm_nominal appears
'    MsgBox "PK = " & PK & vbCrLf & _
'            "Me.chkInclUnposted = " & Me.chkInclUnposted & vbCrLf & _
'            "Me.txtStartAcPrd = " & Me.txtStartAcPrd & vbCrLf & _
'            "Me.txtEndAcPrd =   " & Me.txtEndAcPrd

    ' pass in our arguments before we pass in the ID
    Forms(gstrNominal).frmNominalArgs = _
                        "Nominal Record|" & _
                        IIf(Me.chkInclUnposted, "Incl|", "xxxx|") & _
                        Me.txtStartAcPrd & "|" & Me.txtEndAcPrd
    ' pass the current record ID via Let property
    Forms(gstrNominal).frmNominalID = PK
    
  'End If
 
Exit_Handler:
    Exit Sub
Err_Handler:
    Call LogError(Err.Number, Err.Description, Me.Name & ":tvw_TreeviewNodeDblClick", , ShowErrors)
    Resume Exit_Handler
End Sub
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:58
Joined
Oct 29, 2018
Messages
14,202
Hi. Is this happening on all copies of the FE on all machines? Was there any error number or description in the log to help point to the cause of the problem?
 

isladogs

CID VIP
Local time
Today, 12:58
Joined
Jan 14, 2017
Messages
14,471
In the VBE, go to Tools...Options ...General tab and make sure Error Trapping is set to Break on Unhandled Errors ...(NOT Break on all errors)

Next add error handling code to all event procedures. Include the error number/description in your code.
If you have MZ Tools, add line numbers to your code and include that in your error handling as well.

Also step through your code to determine what triggers the error / crash.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 07:58
Joined
May 21, 2018
Messages
4,544
The code you are using appears to be from a class module I wrote a long time ago. Not sure if that has anything to do with it. If you can post I can take a look. If this is not an updated version of the class you can get it here.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 07:58
Joined
May 21, 2018
Messages
4,544
Another things Active X treeviews can be a little unstable IMO. If your code is crashing without errors that is likely not a code problem.
I would create a clean database and then import all your objects back in. prior to importing the Treeview forms, delete the treeview controls. Import them and readd the treeview controls. Compact and repair and debug compile.

If you still are having issues you can switch to an MSFORMs version of the treeview. It may be a little more stable
 

GK in the UK

Registered User.
Local time
Today, 12:58
Joined
Dec 20, 2017
Messages
232

MajP, yes it is your tree view. Although I just said I didn't copy and paste any controls into my new form I DID copy and paste the actual tree view control. It IS looking a little suspect.

I wondered if it only happened when I double-click the node from 'empty space' but I just tried highlighting a node, then double clicking and it crashed. No error messages, double-click, I get a second or so of Hourglass then Access quits. Ah-ha. The hourglass is activated in the detail form on first open as the datasheet is populated. So maybe I need to take a closer look at the detail form (even though I get no record written to the log table from the detail form). I need to look closely at the interaction between the two forms.

Posting the actual DB isn't so much a problem, as getting some data in. If I upload an empty DB you'll have to populate some data. I will at some point upload the DB (If only for critique) but I need to get some demo data populated.

Anyway I've already got some good pointers to diagnosis, I'm going to try those things. In the meantime I can try the import all objects thing (I've done this once a while ago so I should be able to do that again).
 

Minty

AWF VIP
Local time
Today, 12:58
Joined
Jul 26, 2013
Messages
8,061
To back up what @MajP has posted I used to have a tree-view control that would regularly corrupt.
It happened so frequently that I ended up storing a back up of the tree-view subform in the database that I could simply copy back after deleting the original.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 07:58
Joined
May 21, 2018
Messages
4,544
Anyway I've already got some good pointers to diagnosis, I'm going to try those things. In the meantime I can try the import all objects thing (I've done this once a while ago so I should be able to do that again)
Unfortunately if this is just crashing and closing out you will not likely be able to trap any error since no run time error is being generated.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 06:58
Joined
Feb 28, 2001
Messages
19,125
The ultimate way decide this is to use the app but be SURE that you have the time and date visible in the task bar, usually at lower right on your screen. The MOMENT you crash, note the time and date. That little date/time segment is usually precise to the minute, which should be good enough. Now that you have that time, click your Windows Start icon (lower left on the taskbar). Scroll down to Windows Administrative Tools, then open Event Viewer. You will have up to maybe five possible logs to examine but some of them might be empty. (That is normal because it just depends on what you were running.)

USUALLY task crashes are in the SYSTEM log. You have the date and time of the crash to the minute and the event logs are sorted by time, most recent times at the top. Scroll down to the right time and see what events are logged. If you have an MSACCESS.EXE event or an event based on something similar to ACExxx.DLL, that will be relevant. You will want to see a status code (a.k.a. condition code) which will be either 800xxxxx or C00xxxxx (eight hexadecimal digits). If you see one of those, post it here along with the name of the module and the name of the program. If there is no such code then it wasn't a task crash, it was just a silent task exit. From your viewpoint, not very helpful. But to us it would be very useful to know which kind of event it was.
 

GK in the UK

Registered User.
Local time
Today, 12:58
Joined
Dec 20, 2017
Messages
232
I *may* have tracked it down.

I explained I have two similar main forms each with their own similar detail forms. The tree view control is common so the spotlight was on it.
It occurred to me there's another common component, the sub form of the two detail forms.

On step through, the sub form Load event and Current event were being called twice each before the detail form itself loaded, which I thought was odd. I deleted the Load and Current event subs which were actually empty bar some old commented out code and all sorts of weird things happened, including, Access insisting on replacing the deleted Current Event sub with a new empty one.

I'm thinking the tree view is in the clear. I'll rebuild the sub form from scratch and see if that fixes it. I may end up duplicating the sub form so each detail form has it's own version to reduce the amount of code branches.

Note to self: make more use of step through. Doc_Man, thank you for that useful info which is now bookmarked. The event is recorded in Application Log as an AppCrash in OLEAUT32.dll
 

GK in the UK

Registered User.
Local time
Today, 12:58
Joined
Dec 20, 2017
Messages
232
Well it did turn out to be the sub form and it was a coding error. Who knew that setting the SourceObject in code closes the sub form then immediately opens it again ? Not me. I was setting the SourceObject early on in the detail form. Probably not even necessary. Other things going on contrived to make Access quit because the sub form wasn't there at the moment when it expected it to be.

I've rejigged the code and (so far) no more quitting.
 

Users who are viewing this thread

Top Bottom