ClaraBarton
Registered User.
- Local time
- Today, 13:36
- Joined
- Oct 14, 2019
- Messages
- 764
@MajP I need to update the branch after adding an item:
I get an object defined error when trying to Set tvw
This code is being called from a sub form on the main form that has the treeview.
Do I need to re-initialize the Tree? If I do that I might as well skip the update branch and go for the whole tree?
Suggestions?
Code:
Public Sub UpdateBranch()
Dim tvw As TreeviewForm
Dim ParentNode As Node
Dim newNode As Node
Dim SelectedNode As Node
Dim Key As String
Set tvw = GetItemTreeView
If Not tvw.NodeExists("IT" & Me.ItemID) Then
Key = CStr("IT" & Me.ItemID)
Set newNode = tvw.Nodes.Add(, , Key)
Set ParentNode = tvw.Nodes("LO" & Me.Parent.LocDetail.Form.LocID)
newNode.Text = Me.DocNo & " - " & Me.Item
newNode.Tag = "IT"
Forms!frmDetail.FormatNode newNode
tvw.SelectNode (newNode.Key)
tvw.TreeView.SelectedItem.Selected = True
Else
tvw.Nodes("IT" & Me.ItemID).Text = Me.DocNo & " - " & Me.Item
End If
RequerySubforms
End Sub
Code:
Public Function GetItemTreeView() As TreeviewForm
Set GetItemTreeView = Forms("frmDetail").ItemTreeView
End Function
This code is being called from a sub form on the main form that has the treeview.
Do I need to re-initialize the Tree? If I do that I might as well skip the update branch and go for the whole tree?
Suggestions?