运行时,出现出错提示,“实时错误91,对象变量或with或块变量未设置”,如何解决?
运行时,出现出错提示,“实时错误91,对象变量或with或块变量未设置”,如何解决? 编写一高考查询系统,运行时出现如标题所示错误,请问各位高手,如何解决?谢谢
Private Sub Form_Load()
ado.ConnectionString = 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=' + App.Path + '\db1.mdb'
ado.CommandType = adCmdText
ado.RecordSource = 'select * from db1'
ado.Refresh ‘运行至此,出现出错提示“Refresh 的方法 'IAdodc ’失败'
End Sub
Private Sub Label2_Click()
ado.Recordset.Close ‘运行至此,出现出错提示,“实时错误91,对象变量或with或块变量未设置”,
ado.Recordset.Open 'select * from db1 where 准考证号= ' ' + Txt1 + ' ''
If ado.Recordset.EOF Then
MsgBox '数据库中没有你想查询的', 16, '错误'
Else
Form2.Txt1.Text = ado.Recordset.Fields('姓名').Value
Form2.Txt2.Text = ado.Recordset.Fields('性别').Value
Form2.Txt3.Text = ado.Recordset.Fields('语文').Value
Form2.Txt4.Text = ado.Recordset.Fields('数学').Value
Form2.Txt5.Text = ado.Recordset.Fields('外语ï').Value
Form2.Txt6.Text = ado.Recordset.Fields('综合Ï').Value
Form2.Txt7.Text = ado.Recordset.Fields('总分').Value
Form2.Txt8.Text = ado.Recordset.Fields('录取学校').Value
Form2.Show
Form2.Caption = RTrim(ado.Recordset.Fields('姓名').Value) & '的成绩'
End If
End Sub