VB 事实错误‘3021’ BOF 或者EOF 中有一个是'真',或者当天的记录已被删除,所需的操作要求一个当前的记录

mrhomesick 2014-10-29 03:31:53
这个问题我经常遇见 拜托了


这是截图
具体的代码如下:
------------------------------------------------------------

Private Sub cmdSave_Click()
If Text6.Text = "" Or Text7.Text = "" Or Text8.Text = "" Or Text9.Text = "" Or Text10.Text = "" Or Text11.Text = "" Or Text12.Text = "" Or Text13.Text = "" Or Text14.Text = "" Or Combo1.Text = "" Or Combo3.Text = "" Or DTPicker1.Value = "" Or DTPicker2.Value = "" Or DTPicker3.Value = "" Or DTPicker4.Value = "" Then
MsgBox "输入信息不允许空值", , "系统提示"
Exit Sub
End If
If Not IsNumeric(Trim(Text10.Text)) Or Not IsNumeric(Trim(Text11.Text)) Then
MsgBox "请输入正确的信息!", , "系统提示"
Exit Sub
End If
Adodc3.RecordSource = "select * from tab_yzinfo where 业主代号='" & Text5.Text & "'"
Adodc3.Refresh
If Adodc3.Recordset.RecordCount > 0 Then
If Text5.Text = Adodc1.Recordset.Fields("业主代号") Then
MsgBox "已有业主信息!", , "系统提示"
Exit Sub
End If
Else
If Text5.Text <> Adodc3.Recordset.Fields("业主代号") Then
Set adors = cn.Execute("insert into tab_rkinfo (人口编号,姓名,性别,出生日期,文化程度,籍贯,国籍,婚姻状况,工作单位,职业,职务,职称,家庭电话,单位电话,手机,家庭住址,小区名称,大楼名称,房间号,身份证号,户口所在地,暂住证号,房间编号,备注,与户主关系)values('" & Text19 & "','" & Text6 & "','" & Combo2 & "','" & DTPicker1 & "','" & Combo5 & "','" & Combo4 & "','" & Combo3 & "','" & Combo1 & "','" & Text15 & "','" & Combo6 & "','" & Text8 & "','" & Combo7 & "','" & Text14 & "','" & Text17 & "','" & Text16 & "','" & Text1 & "','" & Text2 & "','" & Text3 & "','" & Text7 & "','" & Text7 & "','" & Text13 & "','" & Text9 & "','" & Text4 & "','" & Text18 & "','" & "户主" & "')")
Set adors = cn.Execute("insert into tab_yzinfo values('" & Text5 & "','" & Text6 & "','" & DTPicker1.Value & "','" & Combo1 & "','" & Combo2 & "','" & Combo3 & "','" & Combo4 & "','" & Combo5 & "','" & Combo6 & "','" & Combo7 & "','" & Combo8 & "','" & Text7 & "','" & Text8 & "','" & Text9 & "','" & Text10 & "','" & Text11 & "','" & Text12 & "','" & Text13 & "','" & "text14" & "','" & Text15 & "','" & Text16 & "','" & DTPicker2.Value & "','" & DTPicker3 & "','" & Text17.Text & "','" & DTPicker4.Value & "','" & DTPicker5.Value & "','" & Text18 & "','" & Text1 & "','" & Text2 & "','" & Text4 & "') ")
MsgBox "数据保存成功!", , "系统提示"
End If
End If
Adodc2.Refresh
Set DataGrid1.DataSource = Adodc2
End Sub
---------------------------------------------------------------------------
报错的地方已经用颜色标出 拜托了
...全文
315 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
mrhomesick 2014-11-03
  • 打赏
  • 举报
回复
这个是别人编写的 好吧 后来我给它注释掉 就好了 谢谢你 刚接触VB能向你学习学习?
of123 2014-10-30
  • 打赏
  • 举报
回复
这还要什么“会”? 你上面的条件是 If Adodc3.Recordset.RecordCount > 0 Then,这里是 Else 后的第一句,也就是在没有查询到记录的条件下执行的语句,你还要查 If Text5.Text <> Adodc3.Recordset.Fields("业主代号") Then。你确定这不是玩笑?
mrhomesick 2014-10-29
  • 打赏
  • 举报
回复
怎么没人会吗?

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧