Switchboard Wizard Number of Items on Page

T

Thorson

The default number of items on a switchboard page (set up using the wizard)
is 8, I would like to increase the number to 10 but I am not sure which part
of the code I change... I tried changing this part, but it gave me an error:

' The number of buttons on the form.
Const conNumButtons = 8

I think it is somewhere in this part of the code:

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

' The number of buttons on the form.
Const conNumButtons = 8

Dim con As Object
Dim rs As Object
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")
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
 
F

fredg

The default number of items on a switchboard page (set up using the wizard)
is 8, I would like to increase the number to 10 but I am not sure which part
of the code I change... I tried changing this part, but it gave me an error:
*** snipped ***

Adding a 9th or 10th etc., button is no problem, however you cannot
edit the extra buttons using the switchboard manager. Any changes on
those buttons will have to be done manually.
There are better methods of creating a switchboard, but if you wish to
modify the built-in switchboard here's how.
We'll add just one button.

In design view, select the 8th button. Copy it. Paste it.
Drag this new button and label and align it under the others.
Name this button "Option9".
Change the button's Click Event to:
=HandleButtonClick(9)

Rename the attached label
"OptionLabel9"
Change it's Click event to:
=HandleButtonClick(9)


Open the switchboard code window and change
Const conNumButtons = 8
to
Const conNumButtons = 9

Close the code window and save the changes.

Open the Switchboard Items table

Add a new record.
The actual data depends upon what you want the new button to do.
Let's say you wish to open a form for editing.

SwitchboardID = 1
Item Number = 9
Item Text = Open form whatever (this is the label text)
Command = 3 this is the constant number to open a form for editing)
Argument = frmWhatever (this is the actual name of the form)

Note: You can read the other available Command values in the
Switchboard's HandleButtonClick function code.

Add additional buttons using the same method.

Change SwitchboardID to whatever the actual Switchboard number is.

Again , you won't be able to use the manager to edit the additional
button. You'll need to do it directly in the Switchboard Items table.

A better solution would be to create your own switchboard using an
unbound form and command buttons. If you use the Command button wizard
to add the buttons, Access will even write most of the code for you.
You will have more control over the switchboard appearance,
functionality and usage. Maintenance will be much simpler.
 
T

Thorson

The problem is that I already have developed the switchboard using the
switchboard wizard and I am getting ready to fully release the database for
my users.

I do not have a lot of experience with ACCESS, I have mostly taught myself,
and I have very little experience with writing code.

Are there any good websites you would recommend for directions on designing
a switchboard from scratch?
 
F

fredg

The problem is that I already have developed the switchboard using the
switchboard wizard and I am getting ready to fully release the database for
my users.

I do not have a lot of experience with ACCESS, I have mostly taught myself,
and I have very little experience with writing code.

Are there any good websites you would recommend for directions on designing
a switchboard from scratch?


It's all quite simple.
All you need do is add a new unbound (no record source) form to your
database.
Then, using the Toolbox with the Wizard (the wand with the falling
stars) pressed down, add a command button to the form.
Select the report or form you wish to open from the wizard's list.
Add additional buttons as needed.
Save the form when done.
 
T

Thorson

That sounds easy and I know how to do all that, Thanks.

My only other question would be how do I get the switchboard to navigate to
other menus? On my current switchboard (designed using the switchboard
wizard) when you click a button on the main page it will take you to another
menu and then you can open forms or reports there etc. Designing this part
is what doesn't quite make sense to me.
 
J

Jacob

Simply create another form with those command buttons pointing to the
reports. Its just another form with other command buttons on it.
 
F

fredg

That sounds easy and I know how to do all that, Thanks.

My only other question would be how do I get the switchboard to navigate to
other menus? On my current switchboard (designed using the switchboard
wizard) when you click a button on the main page it will take you to another
menu and then you can open forms or reports there etc. Designing this part
is what doesn't quite make sense to me.

A switchboard is just another form.
Create a second form just like this one, with additional command
buttons. Name this form "MyOtherSwitchboard".
Add a command button to the first switchboard to open this
"MyOtherSwitchboard" form and Close or hide (make Not Visible) the
first switchboard.
Add a button to "MyOtherSwitchboard" form to open (or make Visible)
the first switchboard and Close (or make Not Visible) this second
switchboard.

Note: Because you are not limited to 8 buttons, you may not need to
have the second switchboard form at all.
If you wish to separate the opening forms from opening reports
buttons, for example, just add a Tab control to the unbound form.
Place all buttons that open forms on one tab and all buttons that open
reports on a second tab. Then add an additional tab for Miscellaneous
buttons or whatever.
It looks neat and you don't need a second or third switchboard at all.
When you wish to open a report, just click on the second tab (labeled
Reports) and all of the Report buttons are shown.
 
T

Thorson

Thanks for the advice. I am thinking it would work smoother for my users if
I had a series of switchboards like the switchboard wizard set up. I
currently have 159 switchboard items in my current switchboard. To put these
all on the same form may get really confusing. I do like the tab idea
though, I could do that on parts of the forms.

Thanks.
 

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