• References missing? (Access XP)

    Author
    Topic
    #408228

    I set up a complicated form last year for annual retreat we do at our company and it worked fantastic last year. This year, we are doing the retreat again, but for some reason, now the code behind the form quit working. I checked the code and seems like the references are missing. I’m posting the code and hopefully, someone can help me figure out what reference is missing.

    The Error message:

    “Run Time Error 91
    Object Variable or With block variable not set”

    The coding:

    Private Sub cboCabin_AfterUpdate()
    ‘ Find the record that matches the control.
    Dim rs As Object

    Set rs = Me.Recordset.Clone
    rs.FindFirst “[CabinID] = ” & Str(Me![cboCabin])
    Me.Bookmark = rs.Bookmark

    Forms!frmHousingMatchup!fsubRoom!cboRoom.RowSource = “SELECT [tblroom].[RoomID], [tblroom].[Room]” & “FROM [tblroom]WHERE [CabinID] = ” & Me!CabinID

    Forms!frmHousingMatchup!fsubRoom!cboRoom.Requery

    End Sub

    =====================================

    Set rs = Me.Recordset.Clone line is highlighted in yellow.

    Viewing 1 reply thread
    Author
    Replies
    • #859951

      This code should not need references, since rs is declared as an Object, not as a specific type. If there was a missing reference, you’d get a syntax error about a type being undefined. I would expect the error you get on an unbound form.

      • #859988

        Just what I suspected. However, why am I getting the error message when it worked just fine last year? Also, what does the error message mean?

        Brent

        • #860004

          I think (based on a quick look at the Object Browser) that to use the Recordset.Clone method rather than the RecordsetClone (note the lack of a dot between Recordset and Clone) property, you need to have a reference to either the DAO or ADO library. The simplest solution might just be to get rid of the dot and use the RecordsetClone property (which is part of the Access library).

        • #860005

          I think (based on a quick look at the Object Browser) that to use the Recordset.Clone method rather than the RecordsetClone (note the lack of a dot between Recordset and Clone) property, you need to have a reference to either the DAO or ADO library. The simplest solution might just be to get rid of the dot and use the RecordsetClone property (which is part of the Access library).

        • #860006

          The error message means that you try to refer to an object variable that has not been set. “Me” (that is the form running the code) or “Me.Recordset” are the most likely suspects.

          Although references are not likely to be the cause of the problem, you might experiment. Your database may have references to the Microsoft DAO 3.6 Object Library (DAO) and the Microsoft ActiveX Data Objects 2.n Object Library (ADO); see if removing them or setting them helps – clear both, set only one, or set both – first DAO, then ADO, or first ADO, then DAO.

          Otherwise, I don’t think we can solve this problem without seeing the database.

          • #860077

            Good grief. The solution was SO SIMPLE that it was right under my nose.

            For some reason, the main form (in which there are several subforms nestled in it) lost the data source. All I had to do was to tell the form to go to the table that it was supposed to use and it is working again.

            Sorry.

          • #860078

            Good grief. The solution was SO SIMPLE that it was right under my nose.

            For some reason, the main form (in which there are several subforms nestled in it) lost the data source. All I had to do was to tell the form to go to the table that it was supposed to use and it is working again.

            Sorry.

        • #860007

          The error message means that you try to refer to an object variable that has not been set. “Me” (that is the form running the code) or “Me.Recordset” are the most likely suspects.

          Although references are not likely to be the cause of the problem, you might experiment. Your database may have references to the Microsoft DAO 3.6 Object Library (DAO) and the Microsoft ActiveX Data Objects 2.n Object Library (ADO); see if removing them or setting them helps – clear both, set only one, or set both – first DAO, then ADO, or first ADO, then DAO.

          Otherwise, I don’t think we can solve this problem without seeing the database.

      • #859989

        Just what I suspected. However, why am I getting the error message when it worked just fine last year? Also, what does the error message mean?

        Brent

    • #859952

      This code should not need references, since rs is declared as an Object, not as a specific type. If there was a missing reference, you’d get a syntax error about a type being undefined. I would expect the error you get on an unbound form.

    Viewing 1 reply thread
    Reply To: References missing? (Access XP)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: