[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1165
  • Last Modified:

Access 2000 runtime error 91 when opening switchboard

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.
    Me![Option1].SetFocus
    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"
    Else
        While (Not (rs.EOF))
            Me("Option" & rs![ItemNumber]).Visible = True
            Me("OptionLabel" & rs![ItemNumber]).Visible = True
            Me("OptionLabel" & rs![ItemNumber]).Caption = rs![ItemText]
            rs.MoveNext
        Wend
    End If

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

End Sub
0
jfbelisle89
Asked:
jfbelisle89
  • 3
  • 2
1 Solution
 
jfbelisle89Author Commented:
I format my pc 2 days ago and reinstalled Office, can I be missing ado references........
If so how to recover them????
0
 
stevbeCommented:
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


0
 
jfbelisle89Author Commented:
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 ,..........
0
 
stevbeCommented:
only check the latest version.
0
 
jfbelisle89Author Commented:
FABULOUS !!!!

Thnaks a lot

You saved me!!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now