Results 1 to 8 of 8
  1. #1
    Join Date
    Sep 2004
    Location
    Raleigh, NC
    Posts
    146

    Exclamation Unanswered: The object 'X' isn't open.

    I have a subform, textbox, and command button on a form. The subform contains a list of advertisements, each one with it's own ID. If you want to edit one of the ads, you type the ID number into the textbox and click the command button which executes a query to collect the proper record. As soon as you click the command button, the error message "The object 'X' isn't open" (whereas 'X' = the ID number I typed) appears even though Access runs the query correctly and displays the record. I can edit and save just fine, but this error is getting annoying now. I'm pasting the code from the OnClick property of the command button below... Anyone have any ideas?

    Private Sub Command289_Click()
    On Error GoTo Err_Command289_Click
    Dim stDocName As String
    Dim stLinkCriteria As String
    Dim strMsg As String
    stDocName = "ClassifiedsEdit"
    If Me.ClassID.ControlType = acTextBox Then
    If IsNull(Me.ClassID.Value) Then
    strMsg = "You must enter a ClassID before continuing!" & vbCrLf & "(Error 101)"
    If MsgBox(strMsg, vbQuestion, "Polaris Data Entry Error") = vbOK Then
    Exit Sub
    End If
    Else
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    DoCmd.GoToRecord , [ClassID], acEdit
    End If
    End If
    Exit_Command289_Click:
    Me.ClassID = Null
    Exit Sub
    Err_Command289_Click:
    MsgBox Err.Description
    Resume Exit_Command289_Click
    End Sub

  2. #2
    Join Date
    Sep 2004
    Location
    Reston, VA
    Posts
    86
    Instead of

    DoCmd.GoToRecord , [ClassID], acEdit

    Try using

    DoCmd.GoToRecord , "ClassID", acEdit

    I believe the GoToRecord method uses a string expression for the object name, so when you had [ClassID], it was referencing the actual value and trying to find an object by that name, instead of the name of "ClassID".

  3. #3
    Join Date
    Sep 2004
    Location
    Raleigh, NC
    Posts
    146
    Now I get, "The object 'ClassID' isn't open"

  4. #4
    Join Date
    Sep 2004
    Location
    Reston, VA
    Posts
    86
    Okay, maybe GoToRecord isn't the right command for what you want to do. You say that despite the error, the query still runs and displays the correct record. With GoToRecord, are you trying to move the focus to the ClassID control in the subform? In that case you would use GoToControl or the SetFocus method of the control you want to move to. Or just get rid of the command entirely.

  5. #5
    Join Date
    Sep 2004
    Location
    Raleigh, NC
    Posts
    146
    The situation is this:

    I have a form with a tab control. On the second tab, I have a subform which shows all of the classified ads run by a particular person. I have a command button to a 'new' classified ad and a command button to 'edit' a classified ad already in the list. I created a textbox called "ClassID" that an operator types the classified ad number into and a command button that uses the "ClassID" in a query to find the appropriate record to edit. I have it setup for the record to open in a new popup form and when it does, the record is displayed correctly, but as I stated, I get the "The object 'ClassID' isn't open.".

    The only logical reason that I could come up with is that perhaps the GoToRecord command is looking for the record in a form that's already open. Perhaps GoToRecord runs before the query and therefore, can't find the record because the form hasn't been opened yet?
    Last edited by smacdonaldnc; 10-24-04 at 19:01.

  6. #6
    Join Date
    Sep 2004
    Location
    Raleigh, NC
    Posts
    146
    Well, dunno why it happened, but I removed the following line completely and now it works.

    DoCmd.GoToRecord , "ClassID", acEdit

  7. #7
    Join Date
    Sep 2004
    Location
    Reston, VA
    Posts
    86
    Since the form opens with the correct record, you must have the ClassID in stLinkCriteria in this line:

    DoCmd.OpenForm stDocName, , , stLinkCriteria

    Which filters the form's recordset, yes? So that's probably why it opens correctly and why taking out the GoToRecord doesn't affect it at all. Glad you got it fixed.

  8. #8
    Join Date
    Sep 2004
    Location
    Raleigh, NC
    Posts
    146
    Thanks for all of the help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •