Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Switchboard Problem

Status
Not open for further replies.

jdd3110

MIS
Dec 11, 2003
18
US
I am trying to create a switchboard to navigate through 8 forms that I have already created. I used the switchboard manager as I always do, but on this particular project My switchboard will not run. I am getting an error code the reads "User-defined type not defined" in the code that Dims dbs as Database. Does anyone have any ideas?
Thanks a ton
 
Sure. it's all auto generated by the switchboard manager:

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

    ' The number of buttons on the form.
    Const conNumButtons = 8
    
    Dim dbs As Database
    Dim rst As Recordset
    Dim strSQL 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 dbs = CurrentDb()
    strSQL = "SELECT * FROM [Switchboard Items]"
    strSQL = strSQL & " WHERE [ItemNumber] > 0 AND [SwitchboardID]=" & Me![SwitchboardID]
    strSQL = strSQL & " ORDER BY [ItemNumber];"
    Set rst = dbs.OpenRecordset(strSQL)
    
    ' If there are no options for this Switchboard Page,
    ' display a message.  Otherwise, fill the page with the items.
    If (rst.EOF) Then
        Me![OptionLabel1].Caption = "There are no items for this switchboard page"
    Else
        While (Not (rst.EOF))
            Me("Option" & rst![ItemNumber]).Visible = True
            Me("OptionLabel" & rst![ItemNumber]).Visible = True
            Me("OptionLabel" & rst![ItemNumber]).Caption = rst![ItemText]
            rst.MoveNext
        Wend
    End If

    ' Close the recordset and the database.
    rst.Close
    dbs.Close

End Sub
 
Try creating a reference to the DAO 3.x object library.
Go to your VBA editor. Select tools/references/ then check the box for DAO 3.x. Mine was version 3.6

HTH,
Eric
 
Have you tried stepping thru the code and seeing what bombs where?
 
Thanks man, That worked...Now I have to fix the type mismatch error at
Code:
Set rst = dbs.OpenRecordset(strSQL)
and I should be good to go. Appreciate it.
 
I am Still getting the type mismatch error where the code reads
Code:
Set rst = dbs.OpenRecordSet (strSQL).  Does anyone know what causes this?
 
Hi!

Try to find the declaration and change it to:

[tt]dim dbs as dao.recordset[/tt]

HTH Roy-Vidar
 
Everything that I try just gives me an error on the next line...does the fact that the database has been converted from XP to 97 play a factor?. The thing won't eve work when I delete my switchboard and start from scratch
 
Oups typo,

[tt]dim rst as dao.recordset
dim dbs as dao.database[/tt]

Don't think converting should be an issue. The strange thing, I think, is that Access itself creates this without the correct references.

If you don't make it work, it might be worth trying to create a new database, import all your objectes there (xcept switchboard) and start again.

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top