You could write to the table on close, or you could calculate show it on the fly. Where and how do you want to display this. You could do it in a query, but the information would come from the tvw. I could be done, but you would need a function on the form. The query calls the function passing in the PK and gets the level back.In a query, how do you extract the "Get Level" value for each record that you are able to obtain with the button click? I wish it was as easy as SelectedNodeLevel([E2E_ID]), but that didn't work
Public Sub LoadImages()
Dim nd As Node
For Each nd In TVW.Nodes
nd.Image = DLookup("ResponsibleUnit", "t_E2e", "E2E_ID = " & TVW.getNodePK(nd))
Next nd
End Sub
Thank you again. Nice visual.I do not think logically tying an image to a PK would make sense. Instead I assumed these were taskings an added a field "ResponsibleUnit" (Command) to the table. Then I simply gave the tasks assignements. TRADCOC, FORSCOM, AFC, AMC. I named the bitmaps the same as the commands. So the code is simply this for loading the images
Code:Public Sub LoadImages() Dim nd As Node For Each nd In TVW.Nodes nd.Image = DLookup("ResponsibleUnit", "t_E2e", "E2E_ID = " & TVW.getNodePK(nd)) Next nd End Sub
I do not know why I thought adding the images was hard. It is simply associating the imagelist with the treeview and then using the name of the image.
View attachment 79486
Private Sub tvw_RightClickOffNode()
createCommandBarPopUpNoNode Me, Me.TVW
End Sub
Private Sub tvw_RightClickOnNode(PK As Variant)
Me.TVW.TreeView.Nodes("E2E" & PK).Selected = True
createCommandBarPopUpNode Me, Me.TVW
End Sub
Private Sub tvw_RightClickOffNode()
Me.TVW.TreeView.Nodes("E2E" & PK).Selected = True
createCommandBarPopUpNode Me, Me.TVW
End Sub
Private Sub mTVW_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As stdole.OLE_XPOS_PIXELS, ByVal y As stdole.OLE_YPOS_PIXELS)
Dim NodeHit As Node
If Button = 2 Then
Set NodeHit = mTVW.HitTest(x, y)
If Not NodeHit Is Nothing Then
RaiseEvent RightClickOnNode(Me.getNodePK(NodeHit))
Else
RaiseEvent RightClickOffNode
End If
End If
End Sub
Private Sub mTVW_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As stdole.OLE_XPOS_PIXELS, ByVal y As stdole.OLE_YPOS_PIXELS)
Dim NodeHit As Node
If Button = 2 Then
Set NodeHit = mTVW.HitTest(x, y)
If Not NodeHit Is Nothing Then
RaiseEvent RightClickOffNode
Else
RaiseEvent RightClickOnfNode(Me.getNodePK(NodeHit))
End If
End If
End Sub
strSql = "Update t_E2E SET Level_ID = '" & LevelID & "', [Level] = " & TVW.GetNodeLevel(TVW.getNode("E2E" & PK)) & " WHERE E2E_ID = " & CLng(PK)
That is a typo. Remove the leftover "f". OnNode not OnfNode
I added the calculation and update of the levels. In the autolevel procedure I just added code to write the levels to the table. The procedure to get a level for a given node already existed in the class.
Code:strSql = "Update t_E2E SET Level_ID = '" & LevelID & "', [Level] = " & TVW.GetNodeLevel(TVW.getNode("E2E" & PK)) & " WHERE E2E_ID = " & CLng(PK)
I do not think logically tying an image to a PK would make sense. Instead I assumed these were taskings an added a field "ResponsibleUnit" (Command) to the table. Then I simply gave the tasks assignements. TRADCOC, FORSCOM, AFC, AMC. I named the bitmaps the same as the commands. So the code is simply this for loading the images
Code:Public Sub LoadImages() Dim nd As Node For Each nd In TVW.Nodes nd.Image = DLookup("ResponsibleUnit", "t_E2e", "E2E_ID = " & TVW.getNodePK(nd)) Next nd End Sub
I do not know why I thought adding the images was hard. It is simply associating the imagelist with the treeview and then using the name of the image.
View attachment 79486
I assume you can enter the images via code to the image list, it can be done in .net but not sure of vba. What are you thinking of how you would like it to work. I am guessing you may want to add additional ResponsibleUnits as you go and therefore other icons. If that is the case, I would think you need a table with ResponsibleUnit name and their symbol stored in the DB. But you would probably then have to write code to export to a folder all the icons, put the form into design view, load the images by code into the listview, then save the form. That is my guess, but untried. The other alternative may be simply to have an import image button that allows an import of the image. It will prompt for the correct Name to use. The user will need to make sure it is a .BMP. I will test that to see if it can be done.So, for the pictures, have you seen a more dynamic way to do it, other than the current technique of embedding the images and tagging them?
For the pictures, I'd love for the code to look to a fixed folder on my computer, find the picture with a matching file name and apply it to the treeview. Thus I'm not having to maintain a non-dynamic picture list in 2 locations.For the pictures, I'd love for the code to look to a fixed folder on my computer, find the picture with a matching file name and apply it to the treeview. Thus I'm not having to maintain a non-dynamic picture list in 2 locations.