ba*******@hotmail.com (Michael Keene) wrote ...
I have a query that I'd like to add to my switchboard, but when I use
the switchboard manager I only get the option to run a report, a macro
or open a form. Is there a way to add a query without making it a
macro?
I assume you used the Switchboard Manager to generate the switchboard?
You can add more functionality to the code, but the Switchboard
Manager won't support it--you'll need to add a button with some sort
of dummy functionality, then go directly to the table to change the
command and argument.
To add the ability to run a query, open the code behind the
switchboard form. Find the function called HandleButtonClick. There
are a bunch of constants defined at the beginning; add one for opening
a query, i.e. something like:
Const conCmdRunQuery = 9 'my addition, not supported by wizard
Next, find the end of the Select Case statement and insert a new Case
(*before* the Case Else).
' Run a query (my addition, can't use with wizard)
Case conCmdRunQuery
If IsNull(rst![Argument]) Then
On Error Resume Next
Application.Run "wzmain80.ssq_Entry"
On Error GoTo 0
Else
DoCmd.OpenQuery rst![Argument]
End If
The IsNull stuff is so that if you leave the argument blank, the Query
Wizard will come up.
As far as I recall, that's all that needs to be changed. To run a
query with a particular button, go to its row in the switchboard
table, type the query name in the Argument column, and put your new
constant (9 in my example) in the Command column.
--
HTH,
Martha
(don't google to email)