ClaraBarton
Registered User.
- Local time
- Today, 04:12
- Joined
- Oct 14, 2019
- Messages
- 768
On a treeview click I use this for matching the subform to the clickednode:
The above code is run on a mainform as a current event for a subform: Private WithEvents subFrmItem As Access.Form
Mostly it works, but occasionally when the Children is greater than 0 and the subform was invisible, it returns the strKey has no value (meaning ItemID has no value). If I debug, and press F8 it continues on correctly.
I tried putting a DoEvents before it. No change.
Is there anything else? There isn't a specific error number I can use to ignore.
Code:
Public Sub MatchNode()
Dim strKey As String
Dim ID As Long
Dim Children As Integer
Children = DCount("*", "tblItems", "flocID = " & Me.txtLocID & " And InUse = True")
If Children = 0 Then
subFrmItem.Visible = False
strKey = "LO" & Me.txtLocID
Else
subFrmItem.Visible = True
'ItemID has no value
strKey = "IT" & Nz(subFrmItem.ItemID, "")
End If
tvw.TreeView.Nodes(strKey).Selected = True
tvw.TreeView.SelectedItem.EnsureVisible
tvw.TreeView.DropHighlight = Me.tvw.SelectedNode
End Sub
Mostly it works, but occasionally when the Children is greater than 0 and the subform was invisible, it returns the strKey has no value (meaning ItemID has no value). If I debug, and press F8 it continues on correctly.
I tried putting a DoEvents before it. No change.
Is there anything else? There isn't a specific error number I can use to ignore.