Home Forums Programming General Operation is not allowed when Object is Closed RE: Operation is not allowed when Object is Closed

  • your error is on the vb handling side....

    ADODB.Recordset error '800a0e78' Operation is not allowed when the object is closed.  "

    this error occurs if you refer to the recordset in vb code , but the recordset did not find any records, ie:

    SQL="SELECT * FROM SOMETABLE WHERE X=" & somVBVariable

    Set rs= Conn.Execute(SQL)

    sometextbox.text=rs!SomeField

    The above statement will raise the error above if the rs.EOF was true:

    it should be: SQL="SELECT * FROM SOMETABLE WHERE X=" & somVBVariable

    Set rs= Conn.Execute(SQL)

    if not rs.eof then

    sometextbox.text=rs!SomeField  ' rs("SomeField").Value is the eqivilient syntax

    end if

     

    other similar error s will happen if the rs!SomeField was null, and you try to stick it directly into a variable or object property. (Invalid use of null for example);

    you could also get this same error if you are using the following code:

    SQL="SELECT * FROM SOMETABLE WHERE X=" & somVBVariable

    Set rs.open SQL,Conn

     

    if you did not first do a Set rs=New ADODB.Recordset prior ti the rs.Open command; using the Conn.Execute makes that step unnecessary.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!