Still working on making unique keys for my treeview. I've read up on how to make unique keys and also tried making some from examples found in previous posts in the forum.
The method of making keys I currently does not allow me to have nodes with identical names because the key is[/] the nodes name.
To solve this I tried making a key which adds a nuber on the end.
I keep getting "Element not found" so I'm obviously doing something wrong.
Is this whole "i=i+1"-idea a good way to go when I want to make unique keys?
I would greatly appreciate any comments or suggestions of not too advanced character, as I am in great need of assistance!! thanks alot in advance!
Here is the code which need to have the keys added to it:
The method of making keys I currently does not allow me to have nodes with identical names because the key is[/] the nodes name.
Code:
.Nodes.Add relative:=strNode1Text, relationship:=tvwChild, Key:=strNode2Text, Text:=strVisibleText
To solve this I tried making a key which adds a nuber on the end.
Code:
.Nodes.Add relative:=strNode1Text, relationship:=tvwChild, Key:=strNode2Text[B] & i[/b], Text:=strVisibleText [b]|Where i is "i=i+1"|[/b]
I keep getting "Element not found" so I'm obviously doing something wrong.
Is this whole "i=i+1"-idea a good way to go when I want to make unique keys?
I would greatly appreciate any comments or suggestions of not too advanced character, as I am in great need of assistance!! thanks alot in advance!
Here is the code which need to have the keys added to it:
Code:
Function TreeTilsynshistorikk_Fill()
Dim strMessage As String
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim intVBMsg As Integer
Dim strQuery1 As String
Dim strQuery2 As String
Dim strQuery3 As String
Dim nod As Object
Dim strNode1Text As String
Dim strNode2Text As String
Dim strNode3Text As String
Dim strVisibleText As String
Set dbs = CurrentDb()
strQuery1 = "QryTilsInsTree"
strQuery2 = "QryTilsInsProdTree"
strQuery3 = "QryTilsInsProdDatoTree"
With Me![TreeTilsynshistorikk]
'Fill Level 1
Set rst = dbs.OpenRecordset(strQuery1, dbOpenForwardOnly)
Do Until rst.EOF
strNode1Text = StrConv("Level1" & rst![Initialer], vbLowerCase)
Set nod = .Nodes.Add(Key:=strNode1Text, Text:=rst![Initialer])
'Expand the entire node
nod.Expanded = False
rst.MoveNext
Loop
rst.Close
'Fill Level 2
Set rst = dbs.OpenRecordset(strQuery2, dbOpenForwardOnly)
Do Until rst.EOF
strNode1Text = StrConv("Level1" & rst![Initialer], vbLowerCase)
strNode2Text = StrConv("Level2" & rst![Navn], vbLowerCase)
strVisibleText = rst![Navn]
.Nodes.Add relative:=strNode1Text, relationship:=tvwChild, Key:=strNode2Text, Text:=strVisibleText
rst.MoveNext
Loop
rst.Close
'Fill Level 3
Set rst = dbs.OpenRecordset(strQuery3, dbOpenForwardOnly)
Do Until rst.EOF
strNode2Text = StrConv("Level2" & rst![Navn], vbLowerCase)
strNode3Text = StrConv("Level3" & rst![Dato], vbLowerCase)
strVisibleText = rst![Dato]
.Nodes.Add relative:=strNode2Text, relationship:=tvwChild, Key:=strNode3Text, Text:=strVisibleText
rst.MoveNext
Loop
rst.Close
End With
dbs.Close
End Function