Results 1 to 2 of 2
  1. #1
    pasz is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Jan 2018
    Posts
    1

    Not able to Debug the error in Tree View Code in Access

    Dear All,

    Please anybody help me to debug the error in below given code:

    [Private Sub LoadMyTreeView()
    On Error GoTo Err_Handler

    Dim strSQL As String


    Dim dbs As DAO.Database
    Dim rst As DAO.Recordset

    Dim nod As Node

    Dim iNode As Integer
    Dim strSubName As String
    Dim strPKey As String
    Dim strFedName As String
    Dim strSKey As String
    Dim strXmerName As String
    Dim strAKey As String


    'Clear the treeview nodes

    tvwMyTreeView.Nodes.Clear

    Set dbs = CurrentDb
    strSQL = "SELECT SubName, FedName, XmerName, SubID, FedID, XmerID " & _
    "FROM XmerQuery ORDER BY SubID, FedID;"
    Set rst = dbs.OpenRecordset(strSQL, dbOpenSnapshot)

    If Not rst.BOF Then rst.MoveFirst
    Do Until rst.EOF
    ' Add Substation node
    If strSubName <> rst!SubName Then
    strPKey = rst!SubID & "|"
    MsgBox (strPKey)
    strSubName = rst!SubName
    Set nod = tvwMyTreeView.Nodes.Add(, , strPKey, strSubName, "Sub", "Sub")
    strFedName = ""
    End If

    ' Add Feeder node
    If strFedName <> rst!FedName Then
    strSKey = strPKey & rst!FedID & "|"
    strFedName = rst!FedName
    Set nod = tvwMyTreeView.Nodes.Add(strPKey, tvwChild, strSKey, strFedName, "Fed", "Fed")
    nod.Tag = rst!FedID

    strXmerName = ""
    End If

    ' Add Xmer node
    If strXmerName <> rst!XmerName Then
    strAKey = strSKey & rst!XmerName & "|"
    strXmerName = rst!XmerName
    Set nod = tvwMyTreeView.Nodes.Add(strSKey, tvwChild, strAKey, strXmerName, "Xmer", "Xmer")
    MsgBox (strXmerName)
    nod.Tag = rst!XmerID
    End If

    rst.MoveNext
    Loop


    'LoadMyListView ("")

    Exit_Here:
    Set dbs = Nothing
    Set rst = Nothing
    Exit Sub
    Err_Handler:
    MsgBox Err.Description, vbCritical, "ERROR"
    Resume Next
    End Sub

    ]

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,643
    You haven't mentioned what error you get or what line throws it. If you're not sure, temporarily comment out the On Error line and run the code. When you get the error, hit debug and it will take you to the offending line.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 12-20-2017, 01:00 AM
  2. Help Debug code
    By joym in forum Access
    Replies: 6
    Last Post: 05-24-2017, 04:15 PM
  3. Tree View structure for BOM
    By arunhalyal in forum Access
    Replies: 1
    Last Post: 10-06-2013, 09:49 PM
  4. Replies: 3
    Last Post: 03-08-2013, 06:32 PM
  5. Is There a Way to Debug or Step Through VB code?
    By jeffbase34 in forum Programming
    Replies: 1
    Last Post: 05-28-2009, 08:14 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums