Attach a query to the switchboard

  • Thread starter Thread starter Guest
  • Start date Start date
Hi Ken,

A little vague on the post, but I'm going to assume you
are using the built-in Access Switchboard Manager and you
wish to open a query from the Switchboard. However, the
wizard does not have an option to open queries. Are these
assumptions correct?

If so, you have two options (at least) available to you.

1. You could design your own "Switchboard-type" unbound
form and launch all your procedures from there. I'm sure
most, if not all, of the experts choose this way. They
usually stay away from the Switchboard Manager. Personally
I like the Switchboard Manager and have been able to jazz
it up by adding new things.

2. You can change the Switchboard code a little bit to
achieve your desired result. The Switchboard Manager, as
you have already noticed, will not easily let you open a
query. All we have to do is make a slight change to the
code. Follow these instructions on a BACK-UP COPY!!

Open the Switchboard From in Design mode and go to the
code window. 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 from the Switchboard 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 of the table and the name of the query in
the Argument field.

Hope that helps,
Jeff Conrad
Bend, Oregon
-----Original Message-----
I am making a switchboard. The switchboard will not give
an option to add a query.
 
For all of you who are not as comfortable with changing the code of your Switchboard Manager, you can just create a macro that will open the query for you and attach the macro to the button. Here's how

1. In the Database Window, click Macros under the Objects selection, then New

2. Select OpenQuery in the first Action dropdown and in the arguments below, select the Query you want to open from the Query Name drop down menu. (You can also select the view you want here

3. Save the Macro, exit the Macro

4. In the Switchboard Manager, for the Switchboard Item you want running the query, select the Run Macro Command, and select the Macro name you just created. Exit the Switchboard Manager and try the new button on your Switchboard

That button you just created should open the query you selected in the view you chose. If you don't like the view, simply go back to that Macro and change it

You can also use Macros to open tables, print out reports, etc.

Hope this helps


----- Ken Nease wrote: ----

I am making a switchboard. The switchboard will not give an option to add a query
 
Back
Top