Operation not allowed when object is closed

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kenneth03
    New Member
    • Mar 2012
    • 1

    Operation not allowed when object is closed

    hi can you help me dubug this error

    it says 'operation not allowed when object is closed


    here is the code

    Code:
    Private Sub Command2_Click()
    ch = "0"
    With rsStock
    
        .MoveLast
        Text1.Text = !stockcode + 1
    
    End With
    Text2.Enabled = True
    Text3.Enabled = True
    Text4.Enabled = True
    Text5.Enabled = True
    
    Combo2.Enabled = True
    Command3.Enabled = True
    Command2.Enabled = False
    Command4.Enabled = False
    Command5.Enabled = False
    Last edited by Stewart Ross; Mar 10 '12, 07:21 PM. Reason: Added code tags
  • Stewart Ross
    Recognized Expert Moderator Specialist
    • Feb 2008
    • 2545

    #2
    You do not show how rsStock is being opened, nor do you tell us what you have checked so far.

    Unless rsStock can be shown to be open I would imagine the current problem lies with line 5 - that is, trying to do a MoveLast on a recordset when it is closed. I can't guess why the recordset has been closed as you have not posted the code concerned.

    -Stewart

    Comment

    • rekedtechie
      New Member
      • Feb 2012
      • 51

      #3
      if you used adodb connection..
      TRY to put this code after line 2.
      Code:
      Set rsStock = New ADODB.Recordset
      rsStock.Open "select * from your_table",Your_Active_Connection,adOpenStatic,adLockOptimistic
      rsStock.Requery

      Comment

      Working...