How do I add Queries to a Switchboard in Access 2000?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to link queries to a Switchboard at the 2nd Level. For example, user
opens switchboard and clicks on Queries. Level 2 of the switchboard contains
the items Step 1, Step 2, etc. (I want the user to go through a series of
queries: make-table, delete, and append. And I want the option of opening
them in design view.)

Thanks for your help. jr
 
I want to link queries to a Switchboard at the 2nd Level. For example, user
opens switchboard and clicks on Queries. Level 2 of the switchboard contains
the items Step 1, Step 2, etc. (I want the user to go through a series of
queries: make-table, delete, and append. And I want the option of opening
them in design view.)

Thanks for your help. jr

It's really not necessary to post the same question 10 minutes after
posting the identical question.

I assume you are using the built-in switchboard created by the Access
Switchboard manager.

While it is possible to make changes to the existing switchboard code
to include running a query, it would be much simpler to create a code
module, and have it open any query you want. You can include in the
module some code to ask the user (MsgBox) whether to open the query
normally or in design view. Your switchboard has a RunCode option in
the Edit Switchboard commands.
 
Sorry, today is the first day I used a news group. Thanks for your quick
response.

I'm new to Access. Am a user, not a programmer. Is there a non-techie way
to describe your process? I do not understand Code Module. (I'm taking an
Access class. Up to chap 4 in book. Perhaps Code Modules will be addressed
in a later chapter.)

Thank you. jr
 
Sorry, today is the first day I used a news group. Thanks for your quick
response.

I'm new to Access. Am a user, not a programmer. Is there a non-techie way
to describe your process? I do not understand Code Module. (I'm taking an
Access class. Up to chap 4 in book. Perhaps Code Modules will be addressed
in a later chapter.)

Thank you. jr

If you are taking a class, shouldn't you be asking your instructor
what a module is, or read ahead in your book on how to write the code
needed to open a query?

I won't do all of your homework for you, but I'll point you in the
direction you need to go.

It is the Switchboard created by the Switchboard manager (8 buttons
and a table named Switchboard Items) that you are using isn't it?

If so, on the Main database folder (the one that shows the names of
all your tables, queries, forms reports, macros, modules, click on the
Object tab that says Modules. Then click on New.
When the module window opens, click on Insert + Procedure.

Write the name of the procedure in the Add Procedure dialog box.
Let's name it OpenAQuery
Place a check in the Procedure check box.
Place a check in the Public check box.
Click OK.

The text
Public Sub OpenAQuery()

End Sub

will appear.

Between those 2 lines write:
DoCmd.OpenQuery "TheQueryName"

Change "TheQueryName' to the actual name of the query you wish to run.

Exit and save the module when asked. (You can use any name you wish
except the name of the procedure OpenAQuery.)

Run the switchboard manager (Tools + DataBase Utilities + Switchboard
Manager).
Select the Edit mode and Click on New
Write "Run a query" in the Text box (without the quotes).
Set the Command drop-down box to Run Code.
Write OpenAQuery in the Function name box.
Save all the changes and exit the manager.

When you run the switchboard and click on the Run a query button, the
query should run.

You'll need to now talk to your instructor and find out how to
generate a message box that will ask the user whether to open the
query in design view instead of running it. It isn't difficult.
Then look up the arguments in Access Help on the OpenQuery method, and
adapt the code above to open the query in design view or normally, as
selected by the user.

Good Luck.
 
Fredq,
While searching for how to add a query to a switch board, I came across your
advice to some else, so I tried it.
I made the module and named the function as you did "OpenAQuery"
then replaced "TheQueryName" w/the actual existing query name
"NamesAlphaOrder" so my module looks like this:
The text
Public Sub OpenAQuery()
DoCmd.OpenQuery "NamesAlphaOrder" (without parenthesis)
End Sub
Then, I saved the file under objects+modules+(name=)Queries1
As per your instructions I opened switchboard manager, made the
additions to the main switchboard using edit mode.
Select the Edit mode and Click on New and Write
"Run a query" in the Text box (without the quotes).
 
Back
Top