Firstly, I understand that the Switchboard feature is the work of the devil and should be avoided, but I am helping out a client and I can't redo all his Switchboard menus for him or ask my client to scrap them.
However, on the positive side the Switchboard menus do seem quite stable in this database.
Anyway, my client wants to be able to use Switchboard to open queries directly, Switchboard has a Open Report and Open Form feature but not Open Query.
I've decided to use the Run Code feature of Switchboard, however despite my best efforts I can't get it to work.
Here's what I did. I added a new Module to the database, called CustomMod.
In CustomMod I added the subroutine:
Public Sub OpenQuery(strQuery As String)
If (TypeName(CurrentData.AllQueries(strQuery)) = "Nothing") Then
MsgBox "Query Doesn't Exist: " & strQuery
Else
DoCmd.OpenQuery strQuery
End If
End Sub
Then I added a new Switchboard menu item that runs the exact code:
OpenQuery "Test"
But when activated that gives the error "There was an error executing the command.". What gives??? Running a sub without a parameter works fine.
BTW I am doing this all on Access 2000.
PLEASE HELP !!!
' Run code.
Case conCmdRunCode
If InStr(rs![Argument], " ") > 0 Then
Application.Run Left(rs![Argument], InStr(rs![Argument], " ") - 1), Mid(rs![Argument], 1 + InStr(rs![Argument], " "))
Else
Application.Run rs![Argument]
End If
The Switchboard menu item that runs the exact code (note to remove the double quotes)
OpenQuery Test
CHeers