现有一段代码
sub form_load()set rs =new adodb.recordset
on error goto error_handle
set rs=cn.execute("select * from tn")exit sub
error_handle:
  unload me
end subPrivate Sub Form_Unload(Cancel As Integer)If rs.State = adStateOpen Then rs.State = adStateClosedSet rs = Nothing
End Sub
当没表名时,它说rs.state是只读属性
我想让没表名时执行form_unload事件的内容如何处理

解决方案 »

  1.   

    Private Sub Form_Unload(Cancel As Integer)
    On Error Resume NextIf rs.State = adStateOpen Then rs.State = adStateClosed
    Set rs = Nothing
    End Sub
      

  2.   

    在Form_Load事件里,是不能执行Unload方法的!这样肯定出错!至于如何处理,关注,呵呵......
      

  3.   

    加入On Error Resume Next还是同样的问题出现
    如何处理请大家帮帮忙
      

  4.   

    rs.state是只读属性;不可以将它附值,你可以用rs.close 来关闭记录
      

  5.   

    既然这样,那加一time控件和一boolean变量,用time控件监控boolean变量,在错误代码处设置boolean变量值,在time事件中加unload me即可,但是很浪费资源,各位可有其它的好办法吗?