Access 97 Switchboard problem

J

John Freeze

I have created a small access data base and I was trying to add in a
Switchboard. I have 1 table, 1 form, and 1 report. But after using the
Switchboard manager, and set it all up, then try to open it, I keep getting
the error:
Compile Error:
User-defined type not defined

In this area of 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

Now after many searches of the Knowlage base and trying without luck, as one
option that I was told to do was click on references under tools, but the
option is not available.

Any help would be great. I could even send the file that I am working on.

Thanks in advance.



--
///, ////
\ /, / >.
\ /, _/ /.
\_ /_/ /.
\__/_ <
/<<< \_\_
/,)^>>_._ \
(/ \\ /\\\
// ````
======((`=======

(e-mail address removed)
(e-mail address removed)
(e-mail address removed)
 
K

Ken Snell

You don't say which line of code is causing the problem; when the code gives
the error, which line is "yellow-highlighted"?
 
J

John Freeze

Sorry, its :
Private Sub FillOptions()
that is yellow highlighted.


Ken Snell said:
You don't say which line of code is causing the problem; when the code gives
the error, which line is "yellow-highlighted"?

--
Ken Snell
<MS ACCESS MVP>

John Freeze said:
I have created a small access data base and I was trying to add in a
Switchboard. I have 1 table, 1 form, and 1 report. But after using the
Switchboard manager, and set it all up, then try to open it, I keep getting
the error:
Compile Error:
User-defined type not defined

In this area of 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

Now after many searches of the Knowlage base and trying without luck, as one
option that I was told to do was click on references under tools, but the
option is not available.

Any help would be great. I could even send the file that I am working on.

Thanks in advance.



--
///, ////
\ /, / >.
\ /, _/ /.
\_ /_/ /.
\__/_ <
/<<< \_\_
/,)^>>_._ \
(/ \\ /\\\
// ````
======((`=======

(e-mail address removed)
(e-mail address removed)
(e-mail address removed)
 
T

Tom Wickerath

John,

To check the references, you need to click on Tools > References... when viewing any code
module. You should see a reference set to the "Microsoft DAO 3.51 Object Library" for an
Access 97 database. (For Access 2000, 2002 & 2003, this would be the "Microsoft DAO 3.6
Object Library".

Here are some links that may be helpful to you:

Solving Problems with Library References
http://members.iinet.net.au/~allenbrowne/ser-38.html

Access Reference Problems
http://members.rogers.com/douglas.j.steele/AccessReferenceErrors.html


Tom
___________________________________


I have created a small access data base and I was trying to add in a
Switchboard. I have 1 table, 1 form, and 1 report. But after using the
Switchboard manager, and set it all up, then try to open it, I keep getting
the error:
Compile Error:
User-defined type not defined

In this area of 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

Now after many searches of the Knowlage base and trying without luck, as one
option that I was told to do was click on references under tools, but the
option is not available.

Any help would be great. I could even send the file that I am working on.

Thanks in advance.



--
///, ////
\ /, / >.
\ /, _/ /.
\_ /_/ /.
\__/_ <
/<<< \_\_
/,)^>>_._ \
(/ \\ /\\\
// ````
======((`=======

(e-mail address removed)
(e-mail address removed)
(e-mail address removed)
 
K

Ken Snell

That puzzles me. I don't typically see a compiler error on the opening ID
line of the sub. Is this code in the Visual Basic module of the switchboard?
Is it running on the OnLoad event of the form? What is showing in the
textbox next to the event in the Properties window (Event tab) for the form
when it's open in design view?

The Tools | References is available in Visual Basic Editor; not in the
form's design view.
--
Ken Snell
<MS ACCESS MVP>



John Freeze said:
Sorry, its :
Private Sub FillOptions()
that is yellow highlighted.


Ken Snell said:
You don't say which line of code is causing the problem; when the code gives
the error, which line is "yellow-highlighted"?

--
Ken Snell
<MS ACCESS MVP>

John Freeze said:
I have created a small access data base and I was trying to add in a
Switchboard. I have 1 table, 1 form, and 1 report. But after using the
Switchboard manager, and set it all up, then try to open it, I keep getting
the error:
Compile Error:
User-defined type not defined

In this area of 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

Now after many searches of the Knowlage base and trying without luck,
as
one
option that I was told to do was click on references under tools, but the
option is not available.

Any help would be great. I could even send the file that I am working on.

Thanks in advance.



--
///, ////
\ /, / >.
\ /, _/ /.
\_ /_/ /.
\__/_ <
/<<< \_\_
/,)^>>_._ \
(/ \\ /\\\
// ````
======((`=======

(e-mail address removed)
(e-mail address removed)
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top