When adding new data to the DB, does the autonumber field automatically increase, you don't have to add to it?
I have changed this as shown:

Originally Posted by
si
If you do that, the ID's for the nodes would change from "P" & CStr(lngNodeParent) and "C" & CStr(lngNodeChild) to "N" & rs.Fields("AutoNumber").Value
so would this line
vb Code:
.Nodes.Add "P" & CStr(lngNodeParent), tvwChild, "C" & CStr(lngNodeChild), strNodeChild, "Folder Closed"
now become
vb Code:
.Nodes.Add "N" & rs.Fields("AutoNumber").Value, tvwChild, "N" & rs.Fields("AutoNumber").Value, strNodeChild, "Folder Closed"
or
vb Code:
.Nodes.Add "N" & rs.Fields("AutoNumber").Value, tvwChild, strNodeChild, "Folder Closed"
Because on this line I am now getting the error:
Item cannot be found in the collection corresponding to the name or ordinal
on this line- this part - "N" & rs.Fields("AutoNumber").Value
vb Code:
With tvwCode
.Nodes.Add , , "Source", "Source Code", "Folder Closed"
Do While Not rs.EOF
'check if node is same or different
If strNodeParent <> rs.Fields("NodeName").Value Then
'if different, it's a new parent node
strNodeParent = rs.Fields("NodeName").Value
'add 1 to the key
lngNodeParent = lngNodeParent + 1
'update key number if previous Parent node had children
If lngNodeParent <= lngNodeChild Then lngNodeParent = lngNodeChild + 1
'add the new node, with the new key and it's name
.Nodes.Add "Source", tvwChild, [U]"N" & rs.Fields("AutoNumber").Value[/U], strNodeParent, "Folder Closed"
Do I still need to use these now I am using the AutoNumber field:
vb Code:
'add 1 to the key
lngNodeParent = lngNodeParent + 1