vb运行时,文本框不输入内容或者输入数据库中没有的内容,点查询,会报错BOF或EOF中有一个是真怎么解决
以下是我的代码,怎么改改合适?PrivateSubCommand1_Click()WithAdodc1Adodc1.RecordSource="select*from[s...
以下是我的代码,怎么改改合适?
Private Sub Command1_Click()
With Adodc1
Adodc1.RecordSource = "select * from [sheet1] where [姓名]='" & Text1.Text & "'"
Adodc1.Refresh
If Adodc1.Recordset.EOF Then
MsgBox "未输入或不存在,请重新输入", vbOKOnly, "提示"
Else
End If
Text2.Text = IIf(IsNull(.Recordset("联系方式")), "没有联系方式", .Recordset("联系方式"))
Text3.Text = IIf(IsNull(.Recordset("职称")), "没有职称", .Recordset("职称"))
Text4.Text = IIf(IsNull(.Recordset("专业")), "没留专业", .Recordset("专业"))
Text5.Text = IIf(IsNull(.Recordset("单位")), "没留单位", .Recordset("单位"))
End With
End Sub 展开
Private Sub Command1_Click()
With Adodc1
Adodc1.RecordSource = "select * from [sheet1] where [姓名]='" & Text1.Text & "'"
Adodc1.Refresh
If Adodc1.Recordset.EOF Then
MsgBox "未输入或不存在,请重新输入", vbOKOnly, "提示"
Else
End If
Text2.Text = IIf(IsNull(.Recordset("联系方式")), "没有联系方式", .Recordset("联系方式"))
Text3.Text = IIf(IsNull(.Recordset("职称")), "没有职称", .Recordset("职称"))
Text4.Text = IIf(IsNull(.Recordset("专业")), "没留专业", .Recordset("专业"))
Text5.Text = IIf(IsNull(.Recordset("单位")), "没留单位", .Recordset("单位"))
End With
End Sub 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询