我的vb 数据库查询代码的问题,很是郁闷

来源:百度知道 编辑:UC知道 时间:2024/05/24 04:29:48
Private Sub Command1_Click()

If data1.Recordset.BOF Then
data1.RecordSource = "select * from 表 where 货物名称 = '& Text1.Text&'"
Text2.Text = data1.Recordset.Fields("货物名称")
End If
End Sub

提示错误为:实时错误91,对象变量或with块变量未设置
请高手指点一下
感谢你的帮助,但是还是不行
提示错误为:实时错误91,对象变量或with块变量未设置

我想完成的内容如下:text1.text的值查询数据库
然后在text2.tezt中显示查询到的一个属性信息
谢谢

Private Sub Command1_Click()

If data1.Recordset.BOF Then
data1.RecordSource = "select * from 表 where 货物名称 = '& Text1.Text&'"
data1.Refresh '========加上这句=============
Text2.Text = data1.Recordset.Fields("货物名称")
End If
End Sub