删除 ACCESS 中表记录的最后一行出现了问题,请大侠指点
程序代码:
Private Sub Text5_Change() If Len(Text5) = 13 Then Set cn = CreateObject("ADODB.Connection") Set rs = CreateObject("ADODB.Recordset") cn.Provider = "Microsoft.Jet.OLEDB.4.0" cn.ConnectionString = "Data Source=" & App.Path & "\tmdata.mdb" & " ;Jet OLEDB:Database password= coucongzi" ';Persist Security Info=False" cn.Open rs.CursorLocation = adUseClient SQL = "select * from spxx where sptm = '" & Text5.Text & "' " rs.Open SQL, cn, adOpenDynamic, adLockPessimistic If rs.EOF = True Then MsgBox "不存在'" & Text5.Text & "'这个条码,请重新输入", 16, "错误!" rs.Close cn.Close Else Label1.Caption = rs.Fields("spbm") + Chr(32) + rs.Fields("spys") + Chr(32) + rs.Fields("spcm") + "码" Set cn2 = CreateObject("ADODB.Connection") Set rs2 = CreateObject("ADODB.Recordset") cn2.Provider = "Microsoft.Jet.OLEDB.4.0" cn2.ConnectionString = "Data Source=" & App.Path & "\tmdata.mdb" & " ;Jet OLEDB:Database password= coucongzi" ';Persist Security Info=False" cn2.Open rs2.CursorLocation = adUseClient SQL = "select spbm as 商品编码 ,spys as 颜色 , spcm as 尺码 , sptm as 条码 , spjg as 价格 from zxd " rs2.Open SQL, cn2, adOpenDynamic, adLockPessimistic rs2.AddNew rs2.Fields("商品编码") = rs.Fields("spbm") rs2.Fields("颜色") = rs.Fields("spys") rs2.Fields("尺码") = rs.Fields("spcm") rs2.Fields("条码") = rs.Fields("sptm") rs2.Update Set DataGrid2.DataSource = rs2 Label2.Caption = rs2.RecordCount Command3.Enabled = True Text5.Text = "" End If End If End Sub Private Sub Command6_Click() rs2.MoveLast rs2.Delete 这里出现了错误啊 rs2.Update Set DataGrid2.DataSource = rs2 DataGrid2.Refresh Label2.Caption = rs2.RecordCount End Sub