Switchboard FAQ
Listed below is some information on using the built-in Access Switchboard
Manager Wizard (SBM) that I have posted many times in the newsgroups before. The SBM is
used to create a quick and easy main menu system for navigating in the database. The SBM
is primarily used by Access beginners who do not know how to create their own type of menu
system from scratch. Since the SBM form code can be confusing to new users, there are many
questions asked in the newsgroups. Below are some of the most common questions concerning
the wizard.
Here are some helpful links on using the SBM:
1. http://msdn.microsoft.com/archive/default.asp?url=/archive
/en-us/dnaraccessdev/html/ODC_CreateASwitchBoard.asp
2. http://office.microsoft.com/en-us/assistance/HP051887321033.aspx
3. http://office.microsoft.com/en-us/assistance/HP051887361033.aspx
Frequently Asked Questions:
1. Q: How do I have more than eight items on the
Switchboard form?
2.
Q: When I use the Exit Database option on the form it only
closes the database and not Access as well. What do I need to change in order for Access
to close as well?
3.
Q: I cannot seem to make my form open in Datasheet
View from the Switchboard. What do I need to change in order to make this work?
4. Q: Whenever I open my data entry form from
the Switchboard, it never shows any other records. How do I open the form to show all the
records in the table?
5. Q: Where is the Switchboard Wizard located?
The Help menu in 2000 says it is under the Add-ins Menu, but I do not see it.
6. Q: By default my Switchboard will always
open to the main page. There are times when I want to open it to a specific menu. Is this
possible?
7. Q: Some times I want to send a report directly
to the printer, but the wizard will only preview the report. What do I need to change to
send a report directly to the printer?
8. Q: I deleted my Switchboard form by accident
and I do not have a backup. How do I re-create another Switchboard Form?
9. Q: Whenever my Switchboard form opens with the
database, the Database Window opens as well. I have turned off that option in the Startup
menu, but it still appears. How do I stop this?
10. Q: I would like to add a password prompt when
opening a specific menu of options. I understand this really will not be all that secure,
but I just need something simple. How do I set this up?
11. Q: How do I have both the label on the
Switchboard form and the form caption itself change to match the name of the sub-menus?
12. Q: I wish to change the names of some of my
sub-menus. How do I do that?
13. Q: How do I open a table from the Switchboard?
14. Q: I added a combo box on my Switchboard
form, but when the form is in Normal View I cannot select anything in the combo box. Why
is that?
15.
Q: How do I open/run a
query from the Switchboard?
16.
Q: How do I bold the text of the option
labels as I pass the mouse over them?
17.
Q: How do I have the
Switchboard form be maximized when I open it?
18. Q: How do I have the Switchboard form
appear first when the database opens?
19.
Q: Is it possible to create a back button on your
Switchboard so from your Main Switchboard your Sub-Switchboards or your
Sub-Sub-Switchboards you just click the back button to go the the previous
Switchboard?
20.
Q: Is it possible to launch the Access Report
Wizard from the Switchboard?
21.
Q: Is there a way to print the switchboards
and their entries in a list such as a table of contents?
22.
Q: I cannot seem to
make my form open in PivotTable View or PivotChart View from the
Switchboard. What do I need to change in order to make this work?
1. Q: How do I have more than eight items on the
switchboard form?
A: Make a backup of your database before beginning. You need to
create additional command buttons and labels to match the number of items you want.
Easiest way to do this is to highlight the last command button and label and select Copy.
Then Paste them onto your form to create additional ones. Now make sure you change the
name of the NEW command button(s) to Option9, Option10, etc. Also change the name of the
NEW labels to OptionLabel9, OptionLabel10, etc.
Now go to the properties area of each new command button. In the click event, enter the
following:
=HandleButtonClick(9), =HandleButtonClick(10), etc. to match up with your selection. Do
exactly the same thing for the Click event of the labels (unless you turned those off).
Now go to the code behind the Switchboard form. Scroll down until you come to this line in
the FillOptions Sub:
Const conNumButtons = 8
Change that number to 9, 10 or whatever you need.
Compile the code, save and close the form. Now if you use the Switchboard Manager
interface you are still restricted to 8 items. To add more you have to add the entries
manually into the Switchboard Items Table. Shouldn't be hard to do if you take a few
minutes and see how the records are entered. You can EDIT more than 8 entries from the
Wizard, but cannot ADD more than 8.
You can also follow some directions on
this site:
http://www.techonthenet.com/access/switchboard/increase.php
Top
2. Q: When I use the Exit Database option on the form it
only closes the database and not Access as well. What do I need to change in order for
Access to close as well?
A: Follow these steps, but first make a backup of your
database.
1. Open the Switchboard form in Design View.
2. Go to the code window for this form.
3. Go down to this area:
Private Function HandleButtonClick(intBtn As Integer)
Then look for this bit of code:
' Exit the application.
Case conCmdExitApplication
CloseCurrentDatabase
Change that code to this:
' Exit the application.
Case conCmdExitApplication
DoCmd.Quit
4. Compile the code and save the form.
5. Use the Switchboard Manager to create an option on your main page for exiting. Select
the command option that says "Exit Application." Press that option on the form
in normal view and it should close the database and Access as well.
Top
3. Q: I cannot seem to make my form open in
Datasheet View from the Switchboard. What do I need to change in order to make this work?
A: Follow these steps, but first make a backup of your
database.
You have three options (at least) available to you.
1. You could make your form into a Continuous Form and design it so it *looks* just like a
datasheet. Then open it in Edit mode from the Switchboard.
2. You can change the Switchboard code a little bit to achieve your desired result. The
Switchboard automatically will open a form in Single view. If you change the code to
datasheet view then ALL forms will open in Datasheet view launched from the Switchboard
which is probably not a good thing.
If you would like to have the best of both worlds, follow these instructions on a BACK-UP
COPY.
Open the Switchboard code. Find the area that has this:
' Constants for the commands that can be executed.
Const conCmdGotoSwitchboard = 1
Const conCmdOpenFormAdd = 2
Const conCmdOpenFormBrowse = 3
Const conCmdOpenReport = 4
Const conCmdCustomizeSwitchboard = 5
Const conCmdExitApplication = 6
Const conCmdRunMacro = 7
Const conCmdRunCode = 8
Add one more line to the list like this:
Const conCmdOpenFormDatasheet = 9
Now go a little further down the code until you come to this area:
' Run code.
Case conCmdRunCode
Application.Run rst![Argument]
' Any other command is unrecognized.
Case Else
MsgBox "Unknown option."
In between these two areas we want to add another one for datasheet view. Add in this new
code in the middle so it looks like this:
' Run code.
Case conCmdRunCode
Application.Run rst![Argument]
' Open a form in Datasheet Mode.
Case conCmdOpenFormDatasheet
DoCmd.OpenForm rst![Argument], acFormDS
' Any other command is unrecognized.
Case Else
MsgBox "Unknown option."
Compile and save the form.
Now you will NOT be able to use the Switchboard Wizard to use this option. The Wizard will
only use the 8 pre-defined options. To open a form in Datasheet View you will need to go
directly to the Switchboard Items TABLE and add it yourself. If you study the records you
will figure out what is going on. Just use the number 9 in the Command field to open a
form in datasheet view and showing all records.
3. In the Switchboard Manager, select the "Run Code" option.
In the "Function Name" box enter: OpenMyForm
In a standalone module enter:
Public Function OpenMyForm()
DoCmd.OpenForm "frmMyFormName", acFormDS
End Function
Running this option on the form will cause the module code
to fire and open the form in Datasheet mode.
Top
4. Q: Whenever I open my data entry form from the
Switchboard, it never shows any other records. How do I open the form to show all the
records in the table?
A: One of the options in the Switchboard Wizard is to
"Open Form in Add Mode." If that's the option you selected, the form will open
to a new record and not show any previous records entered.
To solve this, go back to the Switchboard Wizard and select the option that says
"Open Form in Edit
Mode." Now when the form opens it will default to showing all the records. It will,
however, open on
the first record.
Another possibility is that the form itself has it's "Data Entry" property set
to Yes. Go to the form's properties and look for the option on the All or Data tab that
says "Data Entry." If that option says "Yes" then only new records can
be added. Change that to "No" to view all records from the form
Top
5. Q: Where is the Switchboard Wizard located? The
Help menu in 2000 says it is under the Add-ins Menu, but I do not see it.
A: The Help menu for Access 2000 on the location of the
Switchboard Manager is incorrect. It is located under:
Tools | Database Utilities.
See the following Microsoft KB article for more information:
http://support.microsoft.com/default.aspx?scid=kb;en-us;235430
Top
6. Q: By default my Switchboard will always open
to the main page. There are times when I want to open it to a specific menu. Is this
possible?
A: Use this code launched from a command button on another form
somewhere:
Private Sub cmdOpenSwitchboard_Click()
On Error GoTo ErrorPoint
DoCmd.OpenForm "Switchboard"
Forms!Switchboard.Filter = "[ItemNumber] = 0 " _
& "And [SwitchboardID] = 2"
Forms!Switchboard.Refresh
ExitPoint:
Exit Sub
ErrorPoint:
MsgBox "The following error has occurred:" _
& vbNewLine & "Error Number: " & Err.Number _
& vbNewLine & "Error Description: " _
& Err.Description, vbExclamation, _
"Unexpected Error"
Resume ExitPoint
End Sub
What this will do is open the Switchboard form, but display the second menu. You will have
to make sure that the second menu you want to display uses SwitchboardID number 2 in the
Switchboard Items TABLE. Also, this code assumes you haven't changed the name of the
actual Switchboard form. Adjust the code if necessary.
Top
7. Q: Some times I want to send a report directly to
the printer, but the wizard will only preview the report. What do I need to change to send
a report directly to the printer?
A: A couple of options for you. The Switchboard automatically
will open a report in preview mode. If you change the code to print the report then ALL
reports will automatically print launched from the Switchboard which is probably not a
good thing. If you would like to have the best of both worlds, follow these instructions
on a BACK-UP COPY.
Open the Switchboard code. Find the area that has this:
' Constants for the commands that can be executed.
Const conCmdGotoSwitchboard = 1
Const conCmdOpenFormAdd = 2
Const conCmdOpenFormBrowse = 3
Const conCmdOpenReport = 4
Const conCmdCustomizeSwitchboard = 5
Const conCmdExitApplication = 6
Const conCmdRunMacro = 7
Const conCmdRunCode = 8
Add one more line to the list like this:
Const conCmdPrintReport = 9
Now go a little further down the code until you come to this area:
' Open a form.
Case conCmdOpenFormBrowse
DoCmd.OpenForm rst![Argument]
' Open a report.
Case conCmdOpenReport
DoCmd.OpenReport rst![Argument], acPreview
In between these two areas we want to add another one for print report. Add in this new
code in the middle so it looks like this:
' Open a form.
Case conCmdOpenFormBrowse
DoCmd.OpenForm rst![Argument]
' Print a report.
Case conCmdPrintReport
DoCmd.OpenReport rst![Argument]
' Open a report.
Case conCmdOpenReport
DoCmd.OpenReport rst![Argument], acPreview
Compile and save the form.
Now you will NOT be able to use the Switchboard Wizard to use this option. The Wizard will
only use the 8 pre-defined options. To automatically print a report you will need to go
directly to the Switchboard Items TABLE and add it yourself. If you study the records you
will figure out what is going on. Just use the number 9 in the Command field to print a
report without previewing it.
Here is another option as well. In the Switchboard Manager, select the "Run
Code" option.
In the "Function Name" box enter: PrintMyReport
In a standalone module enter:
Public Function PrintMyReport()
DoCmd.OpenReport "ReportNameHere"
End Function
Save the module with a name like basPrintReports.
Hitting that option on the Switchboard form will run the module code which will print the
report. The bad thing about this design is that you will need to make a different function
for EACH report you want to automatically print.
Top
8. Q: I deleted my Switchboard form by accident and I
do not have a backup. How do I re-create another Switchboard Form?
A: If you need to create a new Switchboard Form, but wish to
save the existing data in the Switchboard Items table then follow these steps:
1. Backup your database (always a good thing).
2. Since you deleted the form go ahead and compact the database to clear out any dust
bunnies.
3. Right click on the Switchboard Items table and rename it to "zSwitchboard
Items" (no quotes
though).
4. Run the Switchboard Manager Add-in again. The wizard will say it cannot find a valid
one and ask
if you wish to create a new one. Say Yes. After the first wizard form comes up just close
the
wizard. You will notice that another new Switchboard Items table and Switchboard form have
been
created.
5. Delete the new Switchboard Items table.
6. Rename the table "zSwitchboard Items" back to just Switchboard Items.
7. Compact the database once again.
8. You should be back in business. Make any adjustments to the items by running the wizard
again if
needed.
9. Now make a back-up of your database please!
Top
9. Q: Whenever my Switchboard form opens with the
database, the Database Window opens as well. I have turned off that option in the Startup
menu, but it still appears. How do I stop this?
A: Three possibilities come to mind.
First one.
ACC2002: Database Window Is Displayed When You Click the Application
Icon Even Though You Turned Off the "Display Database Window" Startup Option
http://support.microsoft.com/?id=313915
Second possibility:
The Switchboard Form's Open event probably has some code similar to this:
DoCmd.SelectObject acForm, "Switchboard", True
DoCmd.Minimize
This code will minimize the Database Window, however, it will override any setting you
have in the Startup Properties to hide the window. So find those two lines of code in the
form's code module and delete them. Everything should be just peachy then.
Third possibility:
ACC2002: The Database Window Is Displayed When a Database Is Opened from the
Most Recently Used File List Even After You Clear the "Display Database Window"
Check Box:
http://support.microsoft.com/?id=304092
Top
10. Q: I would like to add a password prompt when
opening a specific menu of options. I understand this really will not be all that secure,
but I just need something simple. How do I set this up?
A: Make a backup of your database BEFORE beginning!
1. Create a new small password form with the following properties:
-Scroll Bars No
-Record Selectors No
-Navigation Buttons No
-Dividing Lines No
-Auto Center Yes
-Pop Up Yes
-Modal Yes
-Border Style Thin
-Control Box No
-Min Max Buttons None
-Close Button No
-Shortcut Menu No
Name the form frmPassword.
Add a text box on this form called txtPassword with an Input Mask of "Password"
(without the quotations).
Add a label called lblPassword and have the caption say something like "Please Enter
Administrator Password." Position just above the text box.
Add a command button called cmdCloseForm that simply closes the form; nothing else in that
code. Like so:
'**************Code Start*********************
Private Sub cmdCloseForm_Click()
On Error GoTo ErrorPoint
DoCmd.Close acForm, "frmPassword"
ExitPoint:
Exit Sub
ErrorPoint:
' Unexpected Error
MsgBox "The following error has occurred:" _
& vbNewLine & "Error Number: " & Err.Number _
& vbNewLine & "Error Description: " & Err.Description _
, vbExclamation, "Unexpected Error"
Resume ExitPoint
End Sub
'**************Code End*********************
Add another command button called cmdShowAdminArea with a caption of "OK" or
something similar and enter the following code into the Click event for this button:
'**************Code Start*********************
Private Sub cmdShowAdminArea_Click()
On Error GoTo ErrorPoint
If Len(Nz(Me!txtPassword, ""))
= 0 Then
MsgBox "Please enter a password before continuing." _
, vbCritical, "Missing Password"
Me.txtPassword.SetFocus
Else
If Me.txtPassword <> "password" Then
' Substitute with your own password between
the quotes
MsgBox "Incorrect Password", vbExclamation,
"Access Denied"
DoCmd.Close acForm, "frmPassword"
Else
Forms!Switchboard.Filter = "[ItemNumber] = 0 And [SwitchboardID] =
2"
Forms!Switchboard.Refresh
DoCmd.Close acForm, "frmPassword"
End If
End If
ExitPoint:
Exit Sub
ErrorPoint:
' Unexpected Error
MsgBox "The following error has occurred:" _
& vbNewLine & "Error Number: " & Err.Number _
& vbNewLine & "Error Description: " & Err.Description _
, vbExclamation, "Unexpected Error"
Resume ExitPoint
End Sub
'**************Code End*********************
This assumes that the Admin Switchboard area you want to protect is number "2"
in the Switchboard Items TABLE. Make sure to change that number to whatever matches your
table value. This also assumes that the NAME of your switchboard form is actually just
"Switchboard." Change the code if you have changed the name. Dress up the
message box with whatever formatting and/or messages you desire.
Use the Switchboard Manager Wizard to create the entry to go to this Admin area. Instead
of using the option that opens up a Switchboard, make it open the frmPassword instead.
Like this:
Edit Switchboard Item:
Text: Go To Admin Area
Command: Open Form In Add Mode
Form: frmPassword
Now when the person clicks on the Switchboard option that says "Go To Admin
Area" the Password form opens up on top. Unless they enter the correct password, the
Switchboard will not change to show the Admin menu. It would also be a good idea to hide
the Database Window from the users.
11. Q: How do I have both the label on the Switchboard
form and the form caption itself change to match the name of the sub-menus?
A: Have this code in the Form's Current event:
Private Sub Form_Current()
' Update the form caption and label and fill in the list of options.
Me.Caption = Nz(Me![ItemText], "")
Me.Label1.Caption = Nz(Me![ItemText], "")
FillOptions
End Sub
Access Newsgroup regular Karl Dewey
has a working sample here using a slightly different technique. Karl uses
OptionLabel1 to display the menu title The menu
is loaded into the Switchboard Items table as item 1 of each
SwitchboardID. He also
removed the command button for Option1, changed the font (color and size)
and centered it in the display.
Thank you Karl for posting your sample
so others can study it.
Top
12. Q: I wish to change the names of some of my
sub-menus. How do I do that?
A: Follow these steps.
1. Re-launch the SBM (Tools | Database Utilities | Switchboard Manager).
If you are using Access 97 it is under the Add-ins menu.
2. When the wizard opens, click on the Switchboard page you wish to edit and then press
the Edit button.
3. On the next form near the top is a field called "Switchboard Name." Just type
over what you have there and give it a new name. Hit Close when finished.
4. Hit Close on the main wizard page to close it.
5. Now open the Switchboard form in normal mode and the various pages should have the new
names.
Top
13. Q: How do I open a table from the Switchboard?
A: I cannot imagine ever having a need to do this in normal
operations. Tables should never be directly accessible to end users. It presents too many
possibilities for screwing things up. No form events can be utilized so there is no
telling what damage users may do to your data. This could be something used by a developer
for debugging purposes, but do not give end users this capability. Now I'll come down off
my soap box and tell you how to do this since this question has actually been asked in the
newsgroups before.
You can change the Switchboard code a little bit to achieve your desired result.
Follow these instructions on a BACK-UP COPY.
Open the Switchboard code. Find the area that has this:
' Constants for the commands that can be executed.
Const conCmdGotoSwitchboard = 1
Const conCmdOpenFormAdd = 2
Const conCmdOpenFormBrowse = 3
Const conCmdOpenReport = 4
Const conCmdCustomizeSwitchboard = 5
Const conCmdExitApplication = 6
Const conCmdRunMacro = 7
Const conCmdRunCode = 8
Add one more line to the list like this:
Const conCmdOpenTable = 9
Now go a little further down the code until you come to this area:
' Run code.
Case conCmdRunCode
Application.Run rst![Argument]
' Any other command is unrecognized.
Case Else
MsgBox "Unknown option."
In between these two areas we want to add another one for opening a table. Add in this new
code in the middle so it looks like this:
' Run code.
Case conCmdRunCode
Application.Run rst![Argument]
' Open a table.
Case conCmdOpenTable
DoCmd.OpenTable rst![Argument], acViewNormal, acEdit
' Any other command is unrecognized.
Case Else
MsgBox "Unknown option."
Compile and save the form.
Now you will NOT be able to use the Switchboard Wizard to use this option. The Wizard will
only use the 8 pre-defined options. To open a table you
will need to go directly to the
Switchboard Items TABLE and add it yourself. If you study the records you will figure out
what is going on. Just use the number 9 in the Command field to open a table in Edit mode
and showing all records. Look up the OpenTable method in Access Help for the other
properties.
Top
14. Q: I added a combo box on my Switchboard form,
but when the form is in Normal View I cannot select anything in the combo box. Why is
that?
A: The form that the wizard creates sets the "Allow
Edits" property to "No." This setting effectively disallows any selection
from combo boxes. All you need to do is open the form in Design View, go to the Properties
list for the form itself, and change the Allow Edits property to "Yes." Save and
close the form. You will now be able to make a selection in the combo box.
Top
15. Q: How do I
open/run a query from the Switchboard?
A: I do not recommend letting
normal users have direct access to queries. It presents too many
possibilities for screwing things up in my opinion. Now I'll come down off
my soap box and tell you how to do this since this question has actually been asked in the
newsgroups before.
You can change the Switchboard code a little bit to achieve your desired result.
Follow these instructions on a BACK-UP COPY.
Open the Switchboard code. Find the area that has this:
' Constants for the commands that can be executed.
Const conCmdGotoSwitchboard = 1
Const conCmdOpenFormAdd = 2
Const conCmdOpenFormBrowse = 3
Const conCmdOpenReport = 4
Const conCmdCustomizeSwitchboard = 5
Const conCmdExitApplication = 6
Const conCmdRunMacro = 7
Const conCmdRunCode = 8
Add one more line to the list like this:
Const conCmdOpenQuery = 9
Now go a little further down the code until you come to this area:
' Run code.
Case conCmdRunCode
Application.Run rst![Argument]
' Any other command is unrecognized.
Case Else
MsgBox "Unknown option."
In between these two areas we want to add another one for opening a
query. Add in this new
code in the middle so it looks like this:
' Run code.
Case conCmdRunCode
Application.Run rst![Argument]
' Open query.
Case conCmdOpenQuery
DoCmd.OpenQuery rst![Argument]
' Any other command is unrecognized.
Case Else
MsgBox "Unknown option."
Compile and save the form.
Now you will NOT be able to use the Switchboard Wizard to use this option. The Wizard will
only use the 8 pre-defined options. To open a query you
will need to go directly to the
Switchboard Items TABLE and add it yourself. If you study the records you will figure out
what is going on. Just use the number 9 in the Command field to open/run
a query.
Top
16. Q: How do I bold
the text of the option labels as I pass the mouse over them?
A: A working sample is worth a thousand
words so download and study away. There is one sample for Access 97 and one
sample that is in 2000 format which will run fine on 2000, 2002, and 2003.
Top
17. Q: How do I
have the Switchboard form be maximized when I open it?
A: Follow these steps, but first make a backup of your
database.
1. Open the Switchboard form in Design View.
2. Go to the code window for this form.
3. Go down to this area:
Private Sub Form_Open(Cancel As Integer)
Then look for this bit of code:
' Move to the switchboard page that is marked as
the default.
Me.Filter = "[ItemNumber] = 0 AND [Argument] =
'Default' "
Me.FilterOn = True
Add in one more line of code as follows:
' Move to the switchboard page that is marked as
the default.
Me.Filter = "[ItemNumber] = 0 AND [Argument] =
'Default' "
Me.FilterOn = True
DoCmd.Maximize
4. Compile the code and save the form.
Now when the Switchboard form opens it
will fill the entire screen area.
Top
18. Q: How do I
have the Switchboard form appear first when the database opens?
A: You can either create an
AutoExec macro and set up an Argument to open this form or simply use the
Startup options of the database. To set up the Startup property just follow
these steps:
1. On the main Access Menu bar go to
Tools | Startup
A small dialog form will appear
2. On the upper right side there is an
option called "Display Form." From the combo box list of forms, simply
select Switchboard from the list (this assumes you have not changed the name
of your Switchboard form).
3. Hit the Ok button to save your
changes.
Now close the database and then reopen.
You should observe that the Switchboard form appears without any user
intervention.
Top
19. Q: Is it
possible to create a back button on your Switchboard so from your Main
Switchboard your Sub-Switchboards or your Sub-Sub-Switchboards you just
click the back button to go the the previous Switchboard?
A: A working sample is worth a thousand
words so download and study away. There is one sample for Access 97 and one
sample that is in 2000 format which will run fine on 2000, 2002, and 2003.
There is a separate "Back" command button in the bottom right corner that
you can use to back out of the sub menus and back up to the main one.
One thing to note is that you should
*not* put an option on the sub menus and sub-sub menus to go back to other
pages because it will throw everything off in this sample. The code I put
together uses a small table to build a "trail of breadcrumbs" so to speak.
As you go down to sub menus and sub-sub menus, the table is keeping track of
where you are going. Clicking the Back button in the bottom right corner
takes you back up to the main menu one back step at a time. As far as I can
tell you can go as "deep" as you want with the sub menus and it appears to
work just fine.
The sample file has some entries in the Switchboard Items table for you to
see the technique in action. Open the Switchboard form and try it out. You
will need to import the Switchboard Form and the table called tblSBM from
the sample file into your database in order for everything to work in your
file. A Reference must be set to the DAO Object Library as well.
Top
20. Q: Is it
possible to launch the Access Report Wizard from the Switchboard?
A: You need to add a new Public
Sub procedure into a standard module like so:
Public Sub
LaunchReportWizard()
DoCmd.RunCommand acCmdNewObjectReport
End Sub
Launch the Switchboard Manager Wizard
again and add an entry onto one of the pages like so:
Text: Open Report Wizard (or whatever you would like)
Command: Run Code
Function Name: LaunchReportWizard
Close everything and then test it out.
Pressing that option on the Switchboard form should launch the Report
Wizard.
Top
21. Q: Is there
a way to print the switchboards and their entries in a list such as a table
of contents?
A: A working sample is worth a
thousand words so download and study away. Just import the report from the
sample database and open it it to see a nice report of your Switchboard
Items table. Please note, this sample assumes you have not modified the name
of the Switchboard Items table. If you have, you'll need to adjust the
Record Source of the report. There is one sample for Access 97 and one
sample in 2000 format that works with Access 2000, 2002, and 2003.
Top
22. Q: I cannot seem to make my form open in
PivotTable View or PivotChart
View from the Switchboard. What do I need to change in order to make this work?
A: Follow these steps, but first make a backup of your
database.
You have several choices, but here is just one option.
You can change the Switchboard code a little bit to achieve your desired result. The
Switchboard automatically will open a form in Single view. If you change the code to
PivotTable or PivotChart view then ALL forms will open in
that view launched from the Switchboard
which is probably not a good thing.
If you would like to have the best of both worlds, follow these instructions on a BACK-UP
COPY to try it our first.
Open the Switchboard code. Find the area that has this:
' Constants for the commands that can be executed.
Const conCmdGotoSwitchboard = 1
Const conCmdOpenFormAdd = 2
Const conCmdOpenFormBrowse = 3
Const conCmdOpenReport = 4
Const conCmdCustomizeSwitchboard = 5
Const conCmdExitApplication = 6
Const conCmdRunMacro = 7
Const conCmdRunCode = 8
Const conCmdOpenPage = 9
Add two more lines to the list like this:
Const conCmdOpenFormPivotTable = 10
Const conCmdOpenFormPivotChart =
11
Now go a little further down the code until you come to this area:
' Open a Data Access Page.
Case conCmdOpenPage
DoCmd.OpenDataAccessPage rs![Argument]
' Any other command is unrecognized.
Case Else
MsgBox "Unknown option."
In between these two areas we want to add another two
more for PivotTable and
PivotChart view. Add in this new
code in the middle so it looks like this:
' Open a Data Access Page.
Case conCmdOpenPage
DoCmd.OpenDataAccessPage rs![Argument]
' Open a form in PivotTable Mode.
Case conCmdOpenFormPivotTable
DoCmd.OpenForm rs![Argument], acFormPivotTable
Open a form in PivotChart
Mode.
Case conCmdOpenFormPivotChart
DoCmd.OpenForm rs![Argument], acFormPivotChart
' Any other command is unrecognized.
Case Else
MsgBox "Unknown option."
Compile and save the form.
Now you will NOT be able to use the Switchboard Wizard to use
these options. The Wizard will
only use the 8 pre-defined options. To open a form in
PivotTable or PivotChart View you will need to go
directly to the Switchboard Items TABLE and add it yourself. If you study the records you
will figure out what is going on. Just use the number 10 in the Command field to open a
form in PivotTable view and number 11 for a PivotChart
view.
Top
|