Results 1 to 6 of 6
  1. #1
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Seattle, Washington, USA
    Posts
    179
    Thanks
    0
    Thanked 0 Times in 0 Posts

    References missing? (Access XP)

    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.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: References missing? (Access XP)

    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.

  3. #3
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Seattle, Washington, USA
    Posts
    179
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: References missing? (Access XP)

    Just what I suspected. However, why am I getting the error message when it worked just fine last year? [img]/forums/images/smilies/smile.gif[/img] Also, what does the error message mean?

    Brent

  4. #4
    5 Star Lounger st3333ve's Avatar
    Join Date
    May 2003
    Location
    Los Angeles, California, USA
    Posts
    705
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: References missing? (Access XP)

    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).

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: References missing? (Access XP)

    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.

  6. #6
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Seattle, Washington, USA
    Posts
    179
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: References missing? (Access XP)

    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. [img]/forums/images/smilies/smile.gif[/img]

    Sorry.

Posting Permissions

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