Results 1 to 2 of 2

Thread: TreeView - rebuilding Autmation Error "... disconnected from its client"

  1. #1
    Join Date
    Dec 2011
    Posts
    2

    TreeView - rebuilding Autmation Error "... disconnected from its client"

    on a tab page on my form I have a treeview control which builds & displays fine when the form is loaded. If I change the data in the underlying table, clear the nodes, and re-build the tree I get the error:

    "Automation Error. The object invoked has disconnected from its client"

    Note: the error occurs intermittently. When I go to DEBUG and simply run from the trapped line of code. It runs.

    Here's he code:

    Code:
    Public Sub CreateStatusNode(ctl As Control)
    Dim conn As ADODB.Connection
    Dim rst_Status As ADODB.Recordset
    Dim sql As String
    'Dim ctl As Control
    If ctl Is Nothing Then Set ctl = Forms!frm_Dashboard.tree_Participants
    
    'strConn = "Data Provider=Microsoft.ACE.OLEDB.12.0;"
    'strConn = strConn & "Data Source = " & CurrentProject.Path & "\" & CurrentProject.Name
    
    'create Parent sql
    sql = "SELECT Status AS [STATUS] FROM tbl_StatList"
    
    ctl.Nodes.Clear
    'Open Parent recordset
    Set conn = New ADODB.Connection
    With conn
        .ConnectionString = "Data Source = " & CurrentProject.Path & "\" & CurrentProject.Name
        .Provider = "Microsoft.ACE.OLEDB.12.0"
        .Open
    End With
    
    Set rst_Status = New ADODB.Recordset
    
    rst_Status.Open sql, conn
       
      ' loop through the rows in the recordset
        With rst_Status
       
            .MoveFirst
            Do Until .EOF
                ctl.Nodes.Add Text:=!Status, Key:=!Status
                .MoveNext
            Loop
            .Close
        End With
    Set rst_Status = Nothing
    conn.Close
    
    Set conn = Nothing
    Set ctl = Nothing
    End Sub
    This ran fine for the last 2 weeks. I don't recall making any changes to the procedure but now it's driving my bats. Any help would be welcomed.

    Dan

  2. #2
    Join Date
    Dec 2011
    Posts
    2
    Sorry,

    I meant to note that it trapped at this line:

    SNIPPET:

    Code:
      ' loop through the rows in the recordset
        With rst_Status
       
            .MoveFirst
            Do Until .EOF
                ctl.Nodes.Add Text:=!Status, Key:=!Status
                .MoveNext
            Loop
            .Close
        End With

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •