Need help with my TreeView!!!

P

Patrick

HI!!
I'm recently been following the thread about the Tree
view. and I'm trying to understand how it works.
But I'm Stuck!!
The following code is supose to give me 3 nodes(last one
being clients name).Under that node, I want the clients
name to be devided into alphabetical nodes. A,B,C, etc..

So far this code allows me to do just that, but the
problem is that all the data will be stored in the first
letter it finds and then, the other letters will be empty..
Can anyone figured-out why my code is doing that,I can't
figure this out...
Thanks in advance for any help,
PAtrick

Code:
Dim dbs As Database
Dim mNode As Node
Dim rsPublishers As Recordset
Dim NewLetter, OldLetter As String

Set dbs = CurrentDb
Set rsPublishers = dbs.OpenRecordset("SELECT * FROM
clients ORDER BY clientName")

' first Node.
Set mNode = treeEx.Nodes.Add() ' Database path.
mNode.Text = dbs.Name

' Second Node.
Set mNode = treeEx.Nodes.Add(1, tvwChild) ' tables name.
mNode.Text = "clients table"
' Third Node.
Set mNode = treeEx.Nodes.Add(2, tvwChild) ' Clients Name
column.
mNode.Text = "clients Name"

' Children of third node.
While Not rsPublishers.EOF
NewLetter = Left(rsPublishers!ClientName, 1)

If OldLetter = NewLetter Then
Set mNode = treeEx.Nodes.Add(4, tvwChild)
mNode.Text = rsPublishers!ClientName
Else
Set mNode = treeEx.Nodes.Add(3, tvwChild)
mNode.Text = NewLetter
Set mNode = treeEx.Nodes.Add(4, tvwChild)
mNode.Text = rsPublishers!ClientName

End If


OldLetter = Left(rsPublishers!ClientName, 1)
rsPublishers.MoveNext
Wend
 

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