Treeview Control Question

T

Trepalium

Hello,

I am using a treeview Control in a form that has a tab control.
The treeview control is located on one of the tabs. When the form
loads it populates the treeview control(has checkboxes enabled on
treeview), bolds certain text based on the SQL table it's pulling
from, and then checks any items that were checked last time the record
was saved. The problem that I am having is that when I move to another
tab and go back to it, all of the bolds and checks are gone. I've
tried redoing the query on tab control and page click actions as well
as trying to set focus on the treeview control with the page or tab
are clicked and even when the treeview loses focus. For some reason
none of it works...

Any know how to keep these changes to remain? I've looked on google
and many forums including google groups. Still I can't find anything
specific to this.

Any help is appreciated.


Thanks,
Trep.
 
T

Trepalium

Hello,

I am using a treeview Control in a form that has a tab control.
The treeview control is located on one of the tabs. When the form
loads it populates the treeview control(has checkboxes enabled on
treeview), bolds certain text based on the SQL table it's pulling
from, and then checks any items that were checked last time the record
was saved. The problem that I am having is that when I move to another
tab and go back to it, all of the bolds and checks are gone. I've
tried redoing the query on tab control and page click actions as well
as trying to set focus on the treeview control with the page or tab
are clicked and even when the treeview loses focus. For some reason
none of it works...

Any know how to keep these changes to remain? I've looked on google
and many forums including google groups. Still I can't find anything
specific to this.

Any help is appreciated.

Thanks,
Trep.

Ok. I managed to get the tab control change to work; however, I am
getting an error when I change between tabs more than once.

I'm getting the following run-time error:

------------------------------------------------------------------------------
Run-time error '-2147417848 (80010108)':

Method 'Add' of object 'Inodes' failed
------------------------------------------------------------------------------




Code is below for the change event.
-------------------------------------------------------------------

Private Sub TabCtl28_Change()
With Me.TreeView2
Dim nodz As Nodes
Set nodz = TreeView2.Nodes
nodz.Clear
Set nodz = Nothing


Dim cnt As Single, root As String, tpe As String, TextID As
String, Txt As String, nodx As Node, reccnt As Single, nod As Node

If D2RE = True Then
sql = "SELECT count (*) count FROM " & tblD2REChecklist
rsdata.Open (sql)
cnt = rsdata("count")
rsdata.Close

sql = "SELECT Root, Type, TextID, Text, NewBranch FROM " &
tblD2REChecklist
rsdata.Open (sql)

rsdata.MoveFirst
ElseIf Partner = True Then
sql = "SELECT count (*) count FROM " & tblPartChecklist
rsdata.Open (sql)
cnt = rsdata("count")
rsdata.Close

sql = "SELECT Root, Type, TextID, Text, NewBranch FROM " &
tblPartChecklist
rsdata.Open (sql)

rsdata.MoveFirst
End If



Do Until cnt = 0
If rsdata("Root") = "+" And rsdata("Type") = "+" Then
root = rsdata("Root")
TextID = rsdata("TextID")
Txt = rsdata("Text")
Set nodx = .Nodes.Add(, , TextID, Txt)
nodx.Bold = True

reccnt = rsdata2.RecordCount
If reccnt <> 0 Then
rsdata2.MoveFirst
Do Until reccnt = 0
If rsdata2("ERRORCATEGORY") = Txt Or
rsdata2("ERRORTYPE") = Txt Or rsdata2("ERRORDETAIL") = Txt And
rsdata2("ERRORRESOLVED") <> -1 Then

nodx.Checked = True

End If
reccnt = reccnt - 1
rsdata2.MoveNext
Loop
End If
Set nodx = Nothing



ElseIf rsdata("NewBranch") = 1 Then
root = rsdata("Root")
TextID = rsdata("TextID")
Txt = rsdata("Text")
Set nodx = .Nodes.Add(root, tvwChild, TextID, Txt)
nodx.Bold = True
reccnt = rsdata2.RecordCount
If reccnt <> 0 Then
rsdata2.MoveFirst
Do Until reccnt = 0
If rsdata2("ERRORCATEGORY") = Txt Or
rsdata2("ERRORTYPE") = Txt Or rsdata2("ERRORDETAIL") = Txt And
rsdata2("ERRORRESOLVED") <> -1 Then

nodx.Checked = True

End If
reccnt = reccnt - 1
rsdata2.MoveNext
Loop
End If
Set nodx = Nothing

ElseIf rsdata("NewBranch") = 0 Then
root = rsdata("Root")
TextID = rsdata("TextID")
Txt = rsdata("Text")
Set nodx = .Nodes.Add(root, tvwChild, TextID, Txt)
reccnt = rsdata2.RecordCount
If reccnt <> 0 Then
rsdata2.MoveFirst
Do Until reccnt = 0
If rsdata2("ERRORCATEGORY") = Txt Or
rsdata2("ERRORTYPE") = Txt Or rsdata2("ERRORDETAIL") = Txt And
rsdata2("ERRORRESOLVED") <> -1 Then

nodx.Checked = True

End If
reccnt = reccnt - 1
rsdata2.MoveNext
Loop
End If
Set nodx = Nothing
End If

rsdata.MoveNext
cnt = cnt - 1
Loop
End With
rsdata.Close

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