SQL Server

R

Richard

Greetings,

After splitting the database and using the upsize wizard I received the
following error from a popup window, run-time error '91': Object variable or
block variable not set. This is has to do with the switchboard. This is the
place where the debugger stops. Set rst = dbs.OpenRecordset(strSql)

code********************************************************

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

' The number of buttons on the form.

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].Visible = True
Me![Command1].Enabled = True
Me![Command1].SetFocus
With Me![OptionLabel1]
.Visible = True
.FontWeight = conFontWeightBold
End With
For intOption = 2 To conNumButtons
Me("Option" & intOption).Visible = False
Me("OptionLabel" & intOption).Visible = False
Me("OptionLabel" & intOption).FontWeight = conFontWeightNormal
Me("Command" & intOption).Enabled = 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("OptionLabel" & rst![ItemNumber]).Visible = True
Me("OptionLabel" & rst![ItemNumber]).Caption = rst![ItemText]
Me("Command" & rst![ItemNumber]).Enabled = True
rst.MoveNext
Wend
End If

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

End Sub
************************************************************

Any suggestions would be very much appreciated.
Thank You.
 
A

Armen Stein

Greetings,

After splitting the database and using the upsize wizard I received the
following error from a popup window, run-time error '91': Object variable or
block variable not set. This is has to do with the switchboard. This is the
place where the debugger stops. Set rst = dbs.OpenRecordset(strSql)

code********************************************************

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

' The number of buttons on the form.

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].Visible = True
Me![Command1].Enabled = True
Me![Command1].SetFocus
With Me![OptionLabel1]
.Visible = True
.FontWeight = conFontWeightBold
End With
For intOption = 2 To conNumButtons
Me("Option" & intOption).Visible = False
Me("OptionLabel" & intOption).Visible = False
Me("OptionLabel" & intOption).FontWeight = conFontWeightNormal
Me("Command" & intOption).Enabled = 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("OptionLabel" & rst![ItemNumber]).Visible = True
Me("OptionLabel" & rst![ItemNumber]).Caption = rst![ItemText]
Me("Command" & rst![ItemNumber]).Enabled = True
rst.MoveNext
Wend
End If

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

End Sub
************************************************************

Any suggestions would be very much appreciated.
Thank You.

Try adding the dbSeeChanges option to your OpenRecordset:

Set rst = dbs.OpenRecordset(strSql, dbOpenDynaset, dbseeChanges)

Armen Stein
Microsoft Access MVP
www.JStreetTech.com
 
R

Richard

Armen Stein said:
Greetings,

After splitting the database and using the upsize wizard I received the
following error from a popup window, run-time error '91': Object variable or
block variable not set. This is has to do with the switchboard. This is the
place where the debugger stops. Set rst = dbs.OpenRecordset(strSql)

code********************************************************

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

' The number of buttons on the form.

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].Visible = True
Me![Command1].Enabled = True
Me![Command1].SetFocus
With Me![OptionLabel1]
.Visible = True
.FontWeight = conFontWeightBold
End With
For intOption = 2 To conNumButtons
Me("Option" & intOption).Visible = False
Me("OptionLabel" & intOption).Visible = False
Me("OptionLabel" & intOption).FontWeight = conFontWeightNormal
Me("Command" & intOption).Enabled = 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("OptionLabel" & rst![ItemNumber]).Visible = True
Me("OptionLabel" & rst![ItemNumber]).Caption = rst![ItemText]
Me("Command" & rst![ItemNumber]).Enabled = True
rst.MoveNext
Wend
End If

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

End Sub
************************************************************

Any suggestions would be very much appreciated.
Thank You.

Try adding the dbSeeChanges option to your OpenRecordset:

Set rst = dbs.OpenRecordset(strSql, dbOpenDynaset, dbseeChanges)

Armen Stein
Microsoft Access MVP
www.JStreetTech.com

Hi Armen,

thanks for your responce, I tried your suggestion Set rst =
dbs.OpenRecordset(strSql, dbOpenDynaset, dbseeChanges) the debugger still
stops on that line.
 
A

Armen Stein

Armen Stein said:
Greetings,

After splitting the database and using the upsize wizard I received the
following error from a popup window, run-time error '91': Object variable or
block variable not set. This is has to do with the switchboard. This is the
place where the debugger stops. Set rst = dbs.OpenRecordset(strSql)

code********************************************************

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

' The number of buttons on the form.

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].Visible = True
Me![Command1].Enabled = True
Me![Command1].SetFocus
With Me![OptionLabel1]
.Visible = True
.FontWeight = conFontWeightBold
End With
For intOption = 2 To conNumButtons
Me("Option" & intOption).Visible = False
Me("OptionLabel" & intOption).Visible = False
Me("OptionLabel" & intOption).FontWeight = conFontWeightNormal
Me("Command" & intOption).Enabled = 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("OptionLabel" & rst![ItemNumber]).Visible = True
Me("OptionLabel" & rst![ItemNumber]).Caption = rst![ItemText]
Me("Command" & rst![ItemNumber]).Enabled = True
rst.MoveNext
Wend
End If

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

End Sub
************************************************************

Any suggestions would be very much appreciated.
Thank You.

Try adding the dbSeeChanges option to your OpenRecordset:

Set rst = dbs.OpenRecordset(strSql, dbOpenDynaset, dbseeChanges)

Armen Stein
Microsoft Access MVP
www.JStreetTech.com

Hi Armen,

thanks for your responce, I tried your suggestion Set rst =
dbs.OpenRecordset(strSql, dbOpenDynaset, dbseeChanges) the debugger still
stops on that line.

Hmmm. Check your References. Make sure that DAO is above ADO in the
list - they both have a Recordset object, maybe you're referencing the
wrong one by default.

Armen Stein
Microsoft Access MVP
www.JStreetTech.com
 
R

Richard

That gives me a compile error
thanks Dorian

mscertified said:
Try:
Dim rst As NEW Recordset

-Dorian

Richard said:
Greetings,

After splitting the database and using the upsize wizard I received the
following error from a popup window, run-time error '91': Object variable or
block variable not set. This is has to do with the switchboard. This is the
place where the debugger stops. Set rst = dbs.OpenRecordset(strSql)

code********************************************************

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

' The number of buttons on the form.

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].Visible = True
Me![Command1].Enabled = True
Me![Command1].SetFocus
With Me![OptionLabel1]
.Visible = True
.FontWeight = conFontWeightBold
End With
For intOption = 2 To conNumButtons
Me("Option" & intOption).Visible = False
Me("OptionLabel" & intOption).Visible = False
Me("OptionLabel" & intOption).FontWeight = conFontWeightNormal
Me("Command" & intOption).Enabled = 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("OptionLabel" & rst![ItemNumber]).Visible = True
Me("OptionLabel" & rst![ItemNumber]).Caption = rst![ItemText]
Me("Command" & rst![ItemNumber]).Enabled = True
rst.MoveNext
Wend
End If

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

End Sub
************************************************************

Any suggestions would be very much appreciated.
Thank You.
 
M

mscertified

Dim rs As New ADODB.Recordset or,
Dim rs As New DAO.Recordset

Richard said:
That gives me a compile error
thanks Dorian

mscertified said:
Try:
Dim rst As NEW Recordset

-Dorian

Richard said:
Greetings,

After splitting the database and using the upsize wizard I received the
following error from a popup window, run-time error '91': Object variable or
block variable not set. This is has to do with the switchboard. This is the
place where the debugger stops. Set rst = dbs.OpenRecordset(strSql)

code********************************************************

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

' The number of buttons on the form.

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].Visible = True
Me![Command1].Enabled = True
Me![Command1].SetFocus
With Me![OptionLabel1]
.Visible = True
.FontWeight = conFontWeightBold
End With
For intOption = 2 To conNumButtons
Me("Option" & intOption).Visible = False
Me("OptionLabel" & intOption).Visible = False
Me("OptionLabel" & intOption).FontWeight = conFontWeightNormal
Me("Command" & intOption).Enabled = 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("OptionLabel" & rst![ItemNumber]).Visible = True
Me("OptionLabel" & rst![ItemNumber]).Caption = rst![ItemText]
Me("Command" & rst![ItemNumber]).Enabled = True
rst.MoveNext
Wend
End If

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

End Sub
************************************************************

Any suggestions would be very much appreciated.
Thank You.
 
S

Steve Sanford

OK, time for some detective work.

In the database window, click on TABLES. Can you see the table
"Switchboard Items"? (I don't think SQL Server likes spaces in object names
- but I could be wrong)

If you saee the table, click on queries, then on NEW in the menu. Cancel the
ADD TABLE dialog box and switch to SQL view.

Paste (or type)

SELECT * FROM [Switchboard Items];

and run it. Are records returned?

If that worked, then switch to SQL view and paste in:

SELECT * FROM [Switchboard Items] WHERE ItemNumber > 0;

and run it. Any errors?

Next step: paste this in the SQL view of the query:


SELECT * FROM [Switchboard Items] WHERE ItemNumber > 0 AND SwitchboardID =
Forms!MyForm.SwitchboardID;


If the above runs without errors, then paste:

SELECT * FROM [Switchboard Items] WHERE ItemNumber > 0 AND SwitchboardID =
Forms!MyForm.SwitchboardID ORDER BY ItemNumber;


Somewhere you should have received an error.


You could also try changing this section of your code:

'----SNIP -----

' 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];"

'------ for debugging ------
'
msgbox strSQL
'
' or
'
' Debug.Print strSQL
'
'------ for debugging ------


Set rst = dbs.OpenRecordset(strSql)


'----SNIP -----

Does the SQL string look correct? If you still have a problem, uncomment the
DEBUG line and run the code. Open the immediate window (ctl-G) and post the
string so we can see how it looks.

HTH
--
Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)


Richard said:
Greetings,

After splitting the database and using the upsize wizard I received the
following error from a popup window, run-time error '91': Object variable or
block variable not set. This is has to do with the switchboard. This is the
place where the debugger stops. Set rst = dbs.OpenRecordset(strSql)

code********************************************************

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

' The number of buttons on the form.

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].Visible = True
Me![Command1].Enabled = True
Me![Command1].SetFocus
With Me![OptionLabel1]
.Visible = True
.FontWeight = conFontWeightBold
End With
For intOption = 2 To conNumButtons
Me("Option" & intOption).Visible = False
Me("OptionLabel" & intOption).Visible = False
Me("OptionLabel" & intOption).FontWeight = conFontWeightNormal
Me("Command" & intOption).Enabled = 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("OptionLabel" & rst![ItemNumber]).Visible = True
Me("OptionLabel" & rst![ItemNumber]).Caption = rst![ItemText]
Me("Command" & rst![ItemNumber]).Enabled = True
rst.MoveNext
Wend
End If

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

End Sub
************************************************************

Any suggestions would be very much appreciated.
Thank You.
 
R

Richard

Thanks for your time and suggestions,

I will have to wait until I go back to work and try your new suggestions
(Steve)
on monday. Up to this point I have tried all other suggestions with no luck.
Will post back on the 15th.
Thanks you all

Steve Sanford said:
OK, time for some detective work.

In the database window, click on TABLES. Can you see the table
"Switchboard Items"? (I don't think SQL Server likes spaces in object names
- but I could be wrong)

If you saee the table, click on queries, then on NEW in the menu. Cancel the
ADD TABLE dialog box and switch to SQL view.

Paste (or type)

SELECT * FROM [Switchboard Items];

and run it. Are records returned?

If that worked, then switch to SQL view and paste in:

SELECT * FROM [Switchboard Items] WHERE ItemNumber > 0;

and run it. Any errors?

Next step: paste this in the SQL view of the query:


SELECT * FROM [Switchboard Items] WHERE ItemNumber > 0 AND SwitchboardID =
Forms!MyForm.SwitchboardID;


If the above runs without errors, then paste:

SELECT * FROM [Switchboard Items] WHERE ItemNumber > 0 AND SwitchboardID =
Forms!MyForm.SwitchboardID ORDER BY ItemNumber;


Somewhere you should have received an error.


You could also try changing this section of your code:

'----SNIP -----

' 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];"

'------ for debugging ------
'
msgbox strSQL
'
' or
'
' Debug.Print strSQL
'
'------ for debugging ------


Set rst = dbs.OpenRecordset(strSql)


'----SNIP -----

Does the SQL string look correct? If you still have a problem, uncomment the
DEBUG line and run the code. Open the immediate window (ctl-G) and post the
string so we can see how it looks.

HTH
--
Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)


Richard said:
Greetings,

After splitting the database and using the upsize wizard I received the
following error from a popup window, run-time error '91': Object variable or
block variable not set. This is has to do with the switchboard. This is the
place where the debugger stops. Set rst = dbs.OpenRecordset(strSql)

code********************************************************

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

' The number of buttons on the form.

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].Visible = True
Me![Command1].Enabled = True
Me![Command1].SetFocus
With Me![OptionLabel1]
.Visible = True
.FontWeight = conFontWeightBold
End With
For intOption = 2 To conNumButtons
Me("Option" & intOption).Visible = False
Me("OptionLabel" & intOption).Visible = False
Me("OptionLabel" & intOption).FontWeight = conFontWeightNormal
Me("Command" & intOption).Enabled = 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("OptionLabel" & rst![ItemNumber]).Visible = True
Me("OptionLabel" & rst![ItemNumber]).Caption = rst![ItemText]
Me("Command" & rst![ItemNumber]).Enabled = True
rst.MoveNext
Wend
End If

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

End Sub
************************************************************

Any suggestions would be very much appreciated.
Thank You.
 
R

Richard

Thanks to all who responded to this thread. I think my solution is to create
a new swithchboard from scratch rather then use a microsoft template.

Thanks again
Richard

Richard said:
Thanks for your time and suggestions,

I will have to wait until I go back to work and try your new suggestions
(Steve)
on monday. Up to this point I have tried all other suggestions with no luck.
Will post back on the 15th.
Thanks you all

Steve Sanford said:
OK, time for some detective work.

In the database window, click on TABLES. Can you see the table
"Switchboard Items"? (I don't think SQL Server likes spaces in object names
- but I could be wrong)

If you saee the table, click on queries, then on NEW in the menu. Cancel the
ADD TABLE dialog box and switch to SQL view.

Paste (or type)

SELECT * FROM [Switchboard Items];

and run it. Are records returned?

If that worked, then switch to SQL view and paste in:

SELECT * FROM [Switchboard Items] WHERE ItemNumber > 0;

and run it. Any errors?

Next step: paste this in the SQL view of the query:


SELECT * FROM [Switchboard Items] WHERE ItemNumber > 0 AND SwitchboardID =
Forms!MyForm.SwitchboardID;


If the above runs without errors, then paste:

SELECT * FROM [Switchboard Items] WHERE ItemNumber > 0 AND SwitchboardID =
Forms!MyForm.SwitchboardID ORDER BY ItemNumber;


Somewhere you should have received an error.


You could also try changing this section of your code:

'----SNIP -----

' 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];"

'------ for debugging ------
'
msgbox strSQL
'
' or
'
' Debug.Print strSQL
'
'------ for debugging ------


Set rst = dbs.OpenRecordset(strSql)


'----SNIP -----

Does the SQL string look correct? If you still have a problem, uncomment the
DEBUG line and run the code. Open the immediate window (ctl-G) and post the
string so we can see how it looks.

HTH
--
Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)


Richard said:
Greetings,

After splitting the database and using the upsize wizard I received the
following error from a popup window, run-time error '91': Object variable or
block variable not set. This is has to do with the switchboard. This is the
place where the debugger stops. Set rst = dbs.OpenRecordset(strSql)

code********************************************************

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

' The number of buttons on the form.

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].Visible = True
Me![Command1].Enabled = True
Me![Command1].SetFocus
With Me![OptionLabel1]
.Visible = True
.FontWeight = conFontWeightBold
End With
For intOption = 2 To conNumButtons
Me("Option" & intOption).Visible = False
Me("OptionLabel" & intOption).Visible = False
Me("OptionLabel" & intOption).FontWeight = conFontWeightNormal
Me("Command" & intOption).Enabled = 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("OptionLabel" & rst![ItemNumber]).Visible = True
Me("OptionLabel" & rst![ItemNumber]).Caption = rst![ItemText]
Me("Command" & rst![ItemNumber]).Enabled = True
rst.MoveNext
Wend
End If

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

End Sub
************************************************************

Any suggestions would be very much appreciated.
Thank You.
 

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