Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / ActiveX Controls / November 2004

Tip: Looking for answers? Try searching our database.

Problem Displayinf Branch in Treeview

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JamesJ - 04 Oct 2004 19:07 GMT
I'm new to the treeview control and need some help. I have tables I use for
my
home video library. tblMovieType contains 2 fields MovieTypeID (number) and
MovieType (text) The table contains 14 records - Action, Drama etc. tblDvd
Contains several fields of which DvdMovieTitle (text) and  MovieTypeID
(number)
are pertinent. I've created a One to Many relationship with the MovieTypeID
fields.
I'm attempting to use the treeview control to display the MovieType field as
the top
node and the branch to display the movie titles (DvdMovieTitle) that are
assigned
to each movie type. The code I pasted is copied from "Access 2000 Power
Programming"
I'm using Access 2003. I don't get any errors but, the code displays the
movie type
in the treeview correctly but I can't get the branch to display the titles.
The only titles
that are displayed are the first 2 records in the recordset which are
displayed under
the correct movie type.
Any help will be extremely appreciated.

James

Private Sub Form_Load()

Dim objCurrNode As Node

Dim dbLocal As Database
Dim rsType As DAO.Recordset, rsTitle As DAO.Recordset

'...Ooen the recordset
Set dbLocal = CurrentDb()
Set rsType = dbLocal.OpenRecordset("tblDvdMovieType", dbOpenDynaset)
Set rsTitle = dbLocal.OpenRecordset("tblDvd", dbOpenDynaset)

'...loop through movie types
Do Until rsType.EOF

'...Add a top node (Type)
Set objCurrNode = Me!axTreeView.Nodes.Add(, , "MovieType" &
CStr(rsType!DvdMovieTypeID), rsType!DvdMovieType, 1)

'objCurrNode.ExpandedImage = 2

If Not rsTitle.EOF Then

Do While rsTitle!DvdMovieTypeID = rsType!DvdMovieTypeID

'...Add a branch to the current top node
Set objCurrNode = Me!axTreeView.Nodes.Add("MovieType" &
CStr(rsType!DvdMovieTypeID), tvwChild, , rsTitle!DvdMovieTitle, 3)

rsTitle.MoveNext

    If rsTitle.EOF Then
       Exit Do
    End If

   Loop

   End If
   rsType.MoveNext

Loop

Me!axTreeView.Refresh

End Sub
Alex Dybenko - 05 Oct 2004 07:08 GMT
James,
code looks ok at first glance, try to debug it and see whay it actually
fill.
and suggest to use Me!axTreeView.Object.Nodes instead of Me!axTreeView.Nodes

Signature

Alex Dybenko (MVP)
http://Alex.Dybenko.com
http://www.PointLtd.com

> I'm new to the treeview control and need some help. I have tables I use
> for my
[quoted text clipped - 67 lines]
>
> End Sub
JamesJ - 05 Oct 2004 10:43 GMT
No hope. Same thing. Might it have anything to do with
the field properties or table properties?

James

> James,
> code looks ok at first glance, try to debug it and see whay it actually
[quoted text clipped - 74 lines]
>>
>> End Sub
Alex Dybenko - 05 Oct 2004 12:41 GMT
i think i know:

sort both recordsets by DvdMovieTypeID - i think this was original idea

Set rsType = dbLocal.OpenRecordset("Select * from tblDvdMovieType Order by
DvdMovieTypeID", dbOpenDynaset)
Set rsTitle = dbLocal.OpenRecordset("Select * from tblDvd Order by
DvdMovieTypeID", dbOpenDynaset)

Signature

Alex Dybenko (MVP)
http://Alex.Dybenko.com
http://www.PointLtd.com

> No hope. Same thing. Might it have anything to do with
> the field properties or table properties?
[quoted text clipped - 34 lines]
>>> the correct movie type.
>>> Any help will be extremely appreciated.

>>> Dim objCurrNode As Node
>>>
[quoted text clipped - 39 lines]
>>>
>>> End Sub
JamesJ - 05 Oct 2004 16:43 GMT
That works fine! Thanks much.

Thanks again,
James

>i think i know:
>
[quoted text clipped - 87 lines]
>>>>
>>>> End Sub
JamesJ - 05 Oct 2004 19:37 GMT
Now after a bit of a change to the properties of the treeview
I'm getting the following error: Index out of bounds
I only made a couple of changes and change ALL back again
I didn't realize I needed to build a bridge to get this to work.

Set objCurrNode = Me!axTreeView.Object.Nodes.Add("MovieType" &
CStr(rsType!DvdMovieTypeID), 4, , rsTitle!DvdMovieTitle, 3)
> That works fine! Thanks much.
>
[quoted text clipped - 92 lines]
>>>>>
>>>>> End Sub
Alex Dybenko - 05 Oct 2004 20:15 GMT
Check that ImageList property set to correct imagelist with all images you
using

Signature

Alex Dybenko (MVP)
http://Alex.Dybenko.com
http://www.PointLtd.com

> Now after a bit of a change to the properties of the treeview
> I'm getting the following error: Index out of bounds
[quoted text clipped - 99 lines]
>>>>>>
>>>>>> End Sub
JamesJ - 06 Oct 2004 11:18 GMT
The code was showing 3 instead of 2. I guess the example I
was using 3 images.
Looks good now.

Thanks, James

> Check that ImageList property set to correct imagelist with all images you
> using
[quoted text clipped - 102 lines]
>>>>>>>
>>>>>>> End Sub
ali - 22 Nov 2004 14:17 GMT
> I'm new to the treeview control and need some help. I have tables I use
> for my
[quoted text clipped - 67 lines]
>
> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.