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
]