Access交流中心

北京 | 上海 | 天津 | 重庆 | 广州 | 深圳 | 珠海 | 汕头 | 佛山 | 中山 | 东莞 | 南京 | 苏州 | 无锡 | 常州 | 南通 | 扬州 | 徐州 | 杭州 | 温州 | 宁波 | 台州 | 福州 | 厦门 | 泉州 | 龙岩 | 合肥 | 芜湖 | 成都 | 遂宁 | 长沙 | 株洲 | 湘潭 | 武汉 | 南昌 | 济南 | 青岛 | 烟台 | 潍坊 | 淄博 | 济宁 | 太原 | 郑州 | 石家庄 | 保定 | 唐山 | 西安 | 大连 | 沈阳 | 长春 | 昆明 | 兰州 | 哈尔滨 | 佳木斯 | 南宁 | 桂林 | 海口 | 贵阳 | 西宁 | 乌鲁木齐 | 包头 |

[5分]运行时错误35601

公道  发表于:2014-03-29 23:48:46  
复制

老师:

此段代码运行到红字处出现错误,是什么原因呢?

运行时错误35601

 Element not Found

代码如下 :


Private Sub Form_Load()



Dim Rec As New ADODB.Recordset
Dim stRecQL As String
Dim Item As Integer
Dim i As Integer
Dim nodindex As Node


Set nodindex = TreeView.Nodes.Add(, , "爷", "销售客户", "K1", "K2")
nodindex.Sorted = True


Rec.Open "大区表", CurrentProject.Connection, adopenkeyset, adlockoptimistic, adcmdtabledirect
For i = 1 To Rec.RecordCount - 1
Set nodindex = TreeView.Nodes.Add("爷", tvwChild, "父" & Rec.Fields("大区ID"), Rec.Fields("大区名称"), "K1", "K2")
nodindex.Sorted = True
Rec.MoveNext
Next
Rec.Close


Rec.Open "省份表", CurrentProject.Connection, adopenkeyset, adlockoptimistic, adcmdtabledirect
For i = 1 To Rec.RecordCount - 1
Set nodindex = TreeView.Nodes.Add("父" & Rec.Fields("所属大区"), tvwChild, "子" & Rec.Fields("省份ID"), Rec.Fields("省份名称"), "K1", "K2")
nodindex.Sorted = True
Rec.MoveNext
Next
Rec.Close
Rec.Open "客户表", CurrentProject.Connection, adopenkeyset, adlockoptimistic, adcmdtabledirect
For i = 1 To Rec.RecordCount - 1
Set nodindex = TreeView.Nodes.Add("子" & Rec.Fields("所属省份"), tvwChild, "孙" & Rec.Fields("客户ID"), Rec.Fields("客户名称"), "K1", "K2")
nodindex.Sorted = True
Rec.MoveNext
Next
Rec.Close




End Sub

 

Top
公道 发表于:2014-03-30 12:22:11
For i = 1 To Rec.RecordCount - 1是错误的,应该将其改为For i = 0 To Rec.RecordCount - 1

公道 发表于:2014-03-30 12:23:33
已经解决了。自己太粗心了。把0写成1了。大家写代码时也一定要细心呀,这个问题我找了将近一天的时间。终于找出来了。

总记录:2篇  页次:1/1 9 1 :