473,770 Members | 1,905 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

TreeView Behavior: "The object invoked has disconnected from it's clients"?

I've got a routine that loads a tree control.

Works a-ok the first time around, then bombs the second. Works the
third, bombs on the fourth....i.e. it works every other time it is
invoked.

Error# always the same: -2214 741 7848, but the message varies between
"Method 'Add' of object INodes failed." and "The object invoked has
disconnected from it's clients." The first one is more common.

Must be something to do with the state of the control. But, for the
life of me, I cannot see anything in the code...but it must be there,
right?

Anybody been here before?

The code: (Google's word wrapping seems to have had it's way with
it...if you're serious about trying to read it, flip an eMail to
20******@FatBel ly.com and I'll ship you an un-wrapped version in a
..txt attachment)
-----------------------------------------------------
Public Function Load_ElementTre e(ByVal theCheckBoxSwit ch As Boolean,
ByRef theTree As Control, ByRef theElementRS As DAO.Recordset,
Optional ByVal theNameFilter As String) As Long
1000 debugStackPush mModuleName & ": Load_ElementTre e"
1001 On Error GoTo Load_ElementTre e_err

' PURPOSE: To load a tree with up to six heirarchy levels
' ACCEPTS: - Switch telling whether-or-not to show a checkbox on
each node
' - Pointer to the tree TB loaded
' - Pointer to DAO recordset containing elements TB
loaded, which must contain the following fields:
' > ElementID: PK to the table that contains detail
informatin for the current entry
' > NameLev1: The name TB used in heirarchy level 1
' > NameLev2...6: As above, but for heirarchy levels 2
through 6
' - Optional string containing a name fragment to filter
the tree for
' RETURNS: Number of fields loaded
'
' NOTES: 1) We only load ACTIVE elements. As far as the user is
concerned, anything with IsDeleted=True
' has fallen off the edge of the earth.
' 2) We're wimping out on the max levels issue. Instead
of writing a loop that concocts sql for
' deeper and deeper levels, we're just in-line coding
for six.
1002 Dim thisDB As DAO.Database
Dim collectionRS As DAO.Recordset
Dim myQuery As DAO.QueryDef
Dim curNode As Node

Dim i As Integer
Dim curNodeText As String
Dim curParentKey As String

Dim prvNameLev1 As String
Dim prvNameLev2 As String
Dim prvNameLev3 As String
Dim prvNameLev4 As String
Dim prvNameLev5 As String
Dim prvNameLev6 As String

Dim curNodeKeyLev1 As String
Dim curNodeKeyLev2 As String
Dim curNodeKeyLev3 As String
Dim curNodeKeyLev4 As String
Dim curNodeKeyLev5 As String
Dim curNodeKeyLev6 As String

Dim loadCount As Long 'number of items actually loaded

Dim itemCount As Long 'strictly for debugging
Dim curNameLev1 As String
Dim curNameLev2 As String
Dim curNameLev3 As String
Dim curNameLev4 As String
Dim curNameLev5 As String
Dim curNameLev6 As String
Dim curElementID As Long

Dim wantRecord As Boolean

1003 DoCmd.Hourglass True
1004 StatusSet "Loading elements..."

1010 With theTree
1011 .Visible = False
1012 .Nodes.Clear

1013 .Checkboxes = theCheckBoxSwit ch
1014 .Indentation = 0
1015 .LineStyle = 1
1016 .Scroll = True
1017 .Sorted = True
1018 .Style = 6
1019 End With

1020 Set thisDB = CurDB()

1040 With theElementRS
1050 Do Until .EOF = True
1051 itemCount = itemCount + 1
1052 curNameLev1 = !NameLev1
1053 curNameLev2 = !NameLev2
1054 curNameLev3 = !NameLev3
1055 curNameLev4 = !NameLev4
1056 curNameLev5 = !NameLev5
1057 curNameLev6 = !NameLev6
1059 curElementID = !ElementID

1060 If Len(theNameFilt er & "") > 0 Then
1061 If InStr(1, !NameLev1, theNameFilter) > 0 Then
1062 wantRecord = True
1063 Else
1064 wantRecord = False
1065 End If
1066 Else
2067 wantRecord = True
2069 End If

1070 If wantRecord = True Then
1079 loadCount = loadCount + 1
1100 If !NameLev1 <> prvNameLev1 Then
1101 prvNameLev1 = !NameLev1
1102 curNodeKeyLev1 = gTreeKeyDelimit er & CStr(!ElementID )
& gTreeKeyDelimit er & "1"
1103 curNodeText = !NameLev1
1109 Set curNode = theTree.Nodes.A dd(, , curNodeKeyLev1,
curNodeText)
1110 prvNameLev2 = "" 'Neccessary to
handle situations where the same field name appears in different
consecutive tables
1111 prvNameLev3 = ""
1112 prvNameLev4 = ""
1113 prvNameLev5 = ""
1119 prvNameLev6 = ""
1199 End If

1200 If !NameLev2 <> prvNameLev2 Then
1201 prvNameLev2 = !NameLev2
1202 If Len(!NameLev2 & "") > 0 Then
1203 curNodeKeyLev2 = gTreeKeyDelimit er &
CStr(!ElementID ) & gTreeKeyDelimit er & "2"
1204 curNodeText = !NameLev2
1205 Set curNode = theTree.Nodes.A dd(curNodeKeyLe v1,
tvwChild, curNodeKeyLev2, curNodeText)
1209 End If
1210 prvNameLev3 = ""
1211 prvNameLev4 = ""
1212 prvNameLev5 = ""
1219 prvNameLev6 = ""
1299 End If

1300 If !NameLev3 <> prvNameLev3 Then
1301 prvNameLev3 = !NameLev3
1302 If Len(!NameLev3 & "") > 0 Then
1303 curNodeKeyLev3 = gTreeKeyDelimit er &
CStr(!ElementID ) & gTreeKeyDelimit er & "3"
1304 curNodeText = !NameLev3
1305 Set curNode = theTree.Nodes.A dd(curNodeKeyLe v2,
tvwChild, curNodeKeyLev3, curNodeText)
1309 End If
1310 prvNameLev4 = ""
1311 prvNameLev5 = ""
1319 prvNameLev6 = ""
1399 End If

1400 If !NameLev4 <> prvNameLev4 Then
1401 prvNameLev4 = !NameLev4
1402 If Len(!NameLev4 & "") > 0 Then
1403 curNodeKeyLev4 = gTreeKeyDelimit er &
CStr(!ElementID ) & gTreeKeyDelimit er & "4"
1404 curNodeText = !NameLev4
1405 Set curNode = theTree.Nodes.A dd(curNodeKeyLe v3,
tvwChild, curNodeKeyLev4, curNodeText)
1409 End If
1410 prvNameLev5 = ""
1411 prvNameLev6 = ""
1499 End If

1500 If !NameLev5 <> prvNameLev5 Then
1501 prvNameLev5 = !NameLev5
1502 If Len(!NameLev5 & "") > 0 Then
1503 curNodeKeyLev5 = gTreeKeyDelimit er &
CStr(!ElementID ) & gTreeKeyDelimit er & "5"
1504 curNodeText = !NameLev5
1505 Set curNode = theTree.Nodes.A dd(curNodeKeyLe v4,
tvwChild, curNodeKeyLev5, curNodeText)
1509 End If
1510 prvNameLev6 = ""
1599 End If

1600 If !NameLev6 <> prvNameLev6 Then
1601 prvNameLev6 = !NameLev6
1602 If Len(!NameLev6 & "") > 0 Then
1603 curNodeKeyLev6 = gTreeKeyDelimit er &
CStr(!ElementID ) & gTreeKeyDelimit er & "6"
1604 curNodeText = !NameLev6
1605 Set curNode = theTree.Nodes.A dd(curNodeKeyLe v5,
tvwChild, curNodeKeyLev6, curNodeText)
1612 End If
1639 End If

1900 curNode.Expande d = False
1901 End If
1902 .MoveNext
1903 Loop
1909 End With

1996 theTree.Visible = True
1997 Load_ElementTre e = loadCount
1998 StatusSet ""
1999 DoCmd.Hourglass False

Load_ElementTre e_xit:
debugStackPop
On Error Resume Next
Set curNode = Nothing
Set myQuery = Nothing
collectionRS.Cl ose
Set collectionRS = Nothing
Set thisDB = Nothing
Exit Function

Load_ElementTre e_err:
bugAlert True, "ItemCount= " & Format$(itemCou nt, "0") & ",
NameLev1='" & curNameLev1 & "', NameLev2='" & curNameLev2 & "',
NameLev3='" & curNameLev3 & "', NameLev4='" & curNameLev4 & "',
NameLev5='" & curNameLev5 & "', NameLev6='" & curNameLev6 & "',
ElementID=" & Format$(curElem entID, "0") & "."
Resume Load_ElementTre e_xit
End Function
-------------------------------------
Nov 13 '05 #1
2 4641
> The code:

Trying to isolate the problem, I created a new from and put a new 6.0
TreeView control on it.

Same error from this code on every other attempt to load it:
-----------------------------------------------------
Private Sub cmdLoad_Click()

With treTest
.Visible = False
.Nodes.Clear
.Nodes.Add , , "!1!", "1"
.Visible = True
End With

End Sub
-----------------------------------------------------

Then I commented out the .Visible=False line and it worked.

viz:
-----------------------------------------------------
Private Sub cmdLoad_Click()

With treTest
' .Visible = False
.Nodes.Clear
.Nodes.Add , , "!1!", "1"
.Visible = True
End With

End Sub
-----------------------------------------------------

This seems like a major issue performance-wise. When the control is
loaded with 500+ items, it happens in the blink of an eye if it is
made invisible first...but takes way too long if it's visible while
being loaded.

Can anybody think of a workaround?
Nov 13 '05 #2
RE/
This seems like a major issue performance-wise. When the control is
loaded with 500+ items,


Looks like the preferred way is DoCmd.Echo False instead of .Visible=False.

At least that's what I did and the performance returned (6 instead of 37 seconds
to load...) but the mystery abend didn't.
--
PeteCresswell
Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2102
by: James Lavery | last post by:
Hi all, We've got a vb.net assembly (dll), which is exposing a COM interface so it can be called from our legacy VB6 application. When we call a particular method (which is designed to return true/false when finished), the method works fine (it is meant to store data in a database, and this part works), but we get the error: "The object invoked has disconnected from its clients" triggered in the VB6 calling application.
1
1129
by: Clas | last post by:
Hi! I have a multi-layer business application written in VB.NET. The client can be either a website or a webform communicting with the bussines-layers through webservices. In "Client-classes" i'm sometimes using Singletons to "store" data which is frequently used and should be accessible from all client-classes. Now I want to use some kind of global declaration on the server to. I want to be able to access the same object from all layers...
12
4131
by: Jose Fernandez | last post by:
Hello. I'm building a web service and I get this error. NEWS.News.CoverNews(string)': not all code paths return a value This is the WebMethod public SqlDataReader CoverNews(string Sport) {
1
4280
by: Robin Dindayal | last post by:
Does anyone know how I can print a fully rendered .aspx to the server's printer? I know that, if I wanted to print to the client's printer it would be easy (ie. use javascript's window.print()). However, I need to print to the server's printer. I need to print the fully rendered .aspx page from the codebehind .aspx.cs page to the server's printer. I've tried using SHDocVw.InternetExplorer and SHDocVw.WebBrowser but I just can't seem...
2
11311
by: martin-g | last post by:
Hi. When the user opens the Excel file, which is at the same time used by my application, it stops calculations and throws an exception with such information: "The object invoked has disconnected from its clients". What can I do to resolve this? My application opens the source excel file using this statement: oRatelistWbk = AppExcel.Workbooks.Open( m_FilePath, Missing.Value, true, Missing.Value, Missing.Value,
2
4726
by: Wimpie van Lingen | last post by:
Hey I have some more questions with regards to Remoting in .NET 2. I'm using TCP with the Binary formatter. My solution consists of 4 projects: - Class Library containing the server classes which Inherits MarshalByRefObject (ok, at this stage it only contains one class... but its gonna grow) - Class Library containing common classes and interfaces that will be shared between all projects. This include interfaces for the server...
0
2357
by: PShark | last post by:
Hi I have a VB6 app that uses MAPI to send and receive emails. My users are able to use the app to send emails successfully, but when there are new emails in the mailbox, the program opens the email but then raises the following error: "Automation error – The object invoked has disconnected from its clients." The same program is installed on over 30 workstations which have roughly the same config Windows Xp and outlook 2003. The error is...
3
15202
by: =?Utf-8?B?cmF1bGF2aQ==?= | last post by:
VS2005 gets this error "The object invoked has disconnected from its clients" does anyone know about a fix for it?
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10099
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10037
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9904
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8931
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6710
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2849
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.