Treeview Error

D

David C. Holley

So essentially we're doing the same thing.

Damir said:
I'm sorry, I made mistake:

It should be:

mNode.Key = CInt(rsPublishers!PubID) & " table1"


mNode.Key = CInt(rsPublishers!PubID) & " table2"

note: there is leading space in " table2" as in MSDN example:

mNode.Key = CInt(rsPublishers!PubID) & " ID"


Let say I have two tables - Table 1 and Table 2

For Table1 I will use T01
For Table2 T02
etc.




I will not use actual table name, but always four characters: leading space
+ three characters to represent Table

So now I have:
mNode.Key = CInt(rsPublishers!PubID) & " T01" 'first table
mNode.Key = CInt(rsPublishers!PubID) & " T02" 'second table
etc


Can I now extract rsPublishers!PubID?

Damir
 
D

Damir Matijevic

David C. Holley said:
So essentially we're doing the same thing.

David,

true, but that's not the point. I wanted to show that there is alternative - really simple way to deal with TV nodes using MSDN example. Nothing else.
So, for benefit all of us:

MSDN example:
http://msdn.microsoft.com/library/d...us/vbcon98/html/vbconusingtreeviewcontrol.asp

(revised)
Private Sub cmdLoad_Click()
Dim rsPublishers As Recordset
Dim rsTitles As Recordset
Set rsPublishers = mDbBiblio. _
OpenRecordset("Publishers", dbOpenDynaset)
Dim intIndex
Do Until rsPublishers.EOF
Set mNode = tvwDB.Nodes.Add(1, tvwChild)
mNode.Text = rsPublishers!Name
mNode.Tag = "Publisher" ' Identifies the table.
mNode.Key = rsPublishers!PubID & " TBLA" 'revised
mNode.Image = "closed"
intIndex = mNode.Index
' While on this record, create a recordset
' using a query that finds only titles that have
' the same PubID. For each record in the
' resulting recordset, add a Node object to the
' TreeView control, and set the new Node object
' properties with the record's Title, ISBN and
' Author fields.
Set rsTitles = mDbBiblio.OpenRecordset _
("select * from Titles Where PubID = " & _
rsPublishers!PubID)
Do Until rsTitles.EOF
Set mNode = tvwDB.Nodes. _
Add(intIndex, tvwChild)
'mNode.Text = rsTitles!TITLE ' Text.
'mNode.Key = rsTitles!ISBN ' Unique ID.
mNode.Text = rsTitles!TITLE & ", " & rsTitles!ISBN 'Text revised mNode.Key = rsTitles!PubID & " TBLB" 'Unique ID revised mNode.Tag = "Authors" ' Table name.
mNode.Image = "smlBook" ' Image.
' Move to next record in rsTitles.
rsTitles.MoveNext
Loop
' Move to next Publishers record.
rsPublishers.MoveNext
Loop
End Sub
-----------------------------------------------------------------------------------------
(air code)


Private Sub tvwDB_NodeClick(ByVal Node As Object)

dim longAutoNumber as Long

If Node.Tag = "Publishers" Then
longAutoNumber = Val(Node.Key) 'rsPublishers!PubID
ElseIf Node.Tag = "Authors" Then
longAutoNumber = Val(Node.Key) 'rsTitles!PubID
End if

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top