GK in the UK
Registered User.
- Local time
- Today, 12:09
- Joined
- Dec 20, 2017
- Messages
- 281
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.
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