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.