Access 2000 runtime error 91 when opening switchboard

Posted on 2006-03-21
Last Modified: 2008-02-01
I get a Access 2000 runtime error 91 when I try to openmy switchboard????????????

Private Sub FillOptions()
' Fill in the options for this switchboard page.

    ' The number of buttons on the form.
    Const conNumButtons = 8
    Dim con As ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim stSql As String
    Dim intOption As Integer
    ' Set the focus to the first button on the form,
    ' and then hide all of the buttons on the form
    ' but the first.  You can't hide the field with the focus.
    For intOption = 2 To conNumButtons
        Me("Option" & intOption).Visible = False
        Me("OptionLabel" & intOption).Visible = False
    Next intOption
    ' Open the table of Switchboard Items, and find
    ' the first item for this Switchboard Page.
    Set con = Application.CurrentProject.Connection
    stSql = "SELECT * FROM [Switchboard Items]"
    stSql = stSql & " WHERE [ItemNumber] > 0 AND [SwitchboardID]=" & Me![SwitchboardID]
    stSql = stSql & " ORDER BY [ItemNumber];"
    Set rs = CreateObject("ADODB.Recordset")
   HERE>>>>>>>>>>>>>>>>>>> rs.Open stSql, con, 1   ' 1 = adOpenKeyset
    ' If there are no options for this Switchboard Page,
    ' display a message.  Otherwise, fill the page with the items.
    If (rs.EOF) Then
        Me![OptionLabel1].Caption = "There are no items for this switchboard page"
        While (Not (rs.EOF))
            Me("Option" & rs![ItemNumber]).Visible = True
            Me("OptionLabel" & rs![ItemNumber]).Visible = True
            Me("OptionLabel" & rs![ItemNumber]).Caption = rs![ItemText]
    End If

    ' Close the recordset and the database.
    Set rs = Nothing
    Set con = Nothing

End Sub
Question by:jfbelisle89

    Author Comment

    I format my pc 2 days ago and reinstalled Office, can I be missing ado references........
    If so how to recover them????
    LVL 39

    Accepted Solution

    open any code window, select References from the Tools menu, scroll until you see Microsoft ActiveX data Objects 2.X

    you can drop the object variable con and remove code that Set con = ...

    you should also change your code to ...

    Set rs = New ADODB.Recordset
    rs.Open stSql, CurrentProject.Connection, adOpenKeyset


    Author Comment

    Sounds good but I get an error
    Names conflicts with existing module, projetc or object library

    Also do I need to check all Microsoft ActiveX data Objects 2.0 , 2.5, 2.6 ,..........
    LVL 39

    Expert Comment

    only check the latest version.

    Author Comment

    FABULOUS !!!!

    Thnaks a lot

    You saved me!!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
    In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
    With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
    With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now