VB问题:对象变量或With块变量未设置
来源:百度知道 编辑:UC知道 时间:2024/05/28 05:40:00
我做的图书检索如绿色部分图所示,当我按查询按钮时没有任何反应,当按退出按钮时出现如中部图所示,当按调试按钮时如最底图所示,图书检索界面的所有代码如下:
Dim rs As ADODB.Recordset
Dim SQL As String
Dim msg As String
Private Sub CmdQuery_Click()
'查询图书信息
Call LoadData '装载数据
End Sub
Private Sub DataGrid1_Click()
End Sub
Private Sub Form_Load()
Call LoadData '装载数据
End Sub
Private Sub LoadData()
'装载数据
'得到查询条件,构建条件
Dim strWhere As String
strWhere = " where 1=1"
'如果图书号被选中
If chkBookNo.Value = 1 Then
strWhere = strWhere & " and 图书号 like '%" & Trim(txtBookNo.Text) & "%'"
End If
'如果ISBN号被选中
If chkISBN.Value = 1 Then
strWhere = strWhere & " and ISBN号 like '%" & Trim(txtISBN.Text) & "%'"
End If
'如果题名被选中
If chkName.Value = 1 Then
strW
Dim rs As ADODB.Recordset
Dim SQL As String
Dim msg As String
Private Sub CmdQuery_Click()
'查询图书信息
Call LoadData '装载数据
End Sub
Private Sub DataGrid1_Click()
End Sub
Private Sub Form_Load()
Call LoadData '装载数据
End Sub
Private Sub LoadData()
'装载数据
'得到查询条件,构建条件
Dim strWhere As String
strWhere = " where 1=1"
'如果图书号被选中
If chkBookNo.Value = 1 Then
strWhere = strWhere & " and 图书号 like '%" & Trim(txtBookNo.Text) & "%'"
End If
'如果ISBN号被选中
If chkISBN.Value = 1 Then
strWhere = strWhere & " and ISBN号 like '%" & Trim(txtISBN.Text) & "%'"
End If
'如果题名被选中
If chkName.Value = 1 Then
strW
问题处在这里:
Private Sub Form_Unload(Cancel As Integer)
'退出操作
图书管理系统.Enabled = True
rs.Close
Unload Me
End Sub
你在其中做了循环调用,Unload Me 会调用 Form_Unload,而后者又执行了前者,如此循环,所以就执行了多次 rs.Close,你将Unload Me改成 End 应该就会解决。
当然在 rs.Close 之前加上一句 On Error Resume Next 更保险
VB 对象变量或with块变量未设置
VB中对象变量或with块变量错误(91号错误)
vb 实时错误‘91’对象变量或 With 块变量没有设置
对象变量或WITH块变量未设置
对象变量或with块变量未设置 在vb程序设计中,出现这个问题是为什么啊
我运行VB程序时出现实时错误‘91’ 对象变量或with块变量未设置
vb+SQL做一个登录界面,报错"对象变量或With块变量未设置"
VB里面连access报“对象变量或with块变量没有设置”怎么解决?详细点好么?我菜得可以~~
为什么 实时错误'91': 对象变量或With块变量未设置
实时错误'91'对象变量或with块变量未设置(在线等)