vb批处理datagrid中的记录
vb窗体中,datagrid默认显示表格中的所有记录,是可以进行批处理的,而我点击窗体上的“查询“按钮,部分记录显示在datagrid中,再批处理就出错误了(功能是,把查询出来的记录,经过处理后,插入到另一个表中)哪出毛病了呢
提示的错误:run-time error'3265'在对应所需名称或序数的集合中,未找到项目 退出时,还提示:缺少用于更新或刷新的基本表信息 错误定位在红色处,怎么改啊
Private Sub Command2_Click()
Dim cn As New ADODB.Connection
intRecCount = Adodc1.Recordset.RecordCount
a = MsgBox("确认批量退休吗!", vbYesNo + vbQuestion, "退休确认")
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db1.mdb"
If a = vbYes Then
Adodc1.Recordset.MoveFirst
For intCounter = 1 To intRecCount
Adodc1.Recordset.Fields("zt") = "退休"
Adodc1.Recordset.Fields("tbsj") = Format(Date, "yyyy-mm-dd") a = Adodc1.Recordset.Fields("bh").Value
b = Adodc1.Recordset.Fields("xm").Value
c = Adodc1.Recordset.Fields("xb").Value
d = Adodc1.Recordset.Fields("id").Value
e = Adodc1.Recordset.Fields("geren").Value
f = Adodc1.Recordset.Fields("cun").Value
g = Adodc1.Recordset.Fields("zhen").Value
H = Adodc1.Recordset.Fields("shi").Value
i = Adodc1.Recordset.Fields("shi75").Value
j = Adodc1.Recordset.Fields("tbsj").Value
k = Adodc1.Recordset.Fields("ys").Value
l = (Adodc1.Recordset.Fields("geren").Value + Adodc1.Recordset.Fields("cun").Value + Adodc1.Recordset.Fields("lx").Value) / Adodc1.Recordset.Fields("ys").Value
l = Round(l, 2) '设置小数为数为2位
m = (Adodc1.Recordset.Fields("zhen").Value + Adodc1.Recordset.Fields("shi").Value + Adodc1.Recordset.Fields("shi75").Value) / Adodc1.Recordset.Fields("ys").Value
m = Round(m, 2)
n = Adodc1.Recordset.Fields("je").Value + Adodc1.Recordset.Fields("lx").Value
cn.Execute ("insert into sdtx (bh,xm,xb,id,geren,cun,zhen,shi,shi75,txsj01,ys,grzh,tczh,tczh1,zhzje) values ('" & a & "','" & b & "','" & c & "','" & d & "','" & e & "','" & f & "','" & g & "','" & H & "','" & i & "',#" & j & "#,'" & k & "','" & l & "','11.67','" & m & "','" & n & "')")
Adodc1.Recordset.MoveNext
Next intCounter
cn.Close
MsgBox "个人账户和统筹账户批设置成功", 64, "账户设置"
Adodc1.Refresh
End If
End Sub