Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding a Queries Option to a Switchboard

Status
Not open for further replies.

CrimsonLily

Technical User
Feb 3, 2003
19
0
0
US
Is there a way to add an option on a switchboard that will run a specific query? I've got it so that you click a selection and a list of possible queries pops up, and this is where the problem occurs. I can't seem to get it to run any of the queries from the form that pops up.

Any suggestions would be very welcome :)
Thanks

Jen
 
If you want to run the query right from the Switchboard you can do the following:

Build a new Module, basSwitchboard. (Some might argue here that what you're about to build really belongs in the Module behing the Switchboard form, but since Access generates that module, I usually put my code in a separate module.)

For each query you want to run from the Switchboard, write a public sub that specifies which query you want to run, and it's arguments. For example:

- - -
Public Sub RunQuery()

DoCmd.OpenQuery "qryYourQuery", acViewNormal, acReadOnly

End Sub

- - -
** This sub should have OnError statements to be "pure", but it will work without them.

In the Switchboard, add an entry for the Query. For the Command entry, use 'Run Code'. For the Function Name, use whatever you called your Sub ('RunQuery' in my example).

If you want to do this from your form instead of the Switchboard, you would put this code in your form's module in the On Click event of your command button. Done this way, the sub should be Private. For example:

- - -
Private Sub cmdRunQuery_Click()

DoCmd.OpenQuery "qryTest", acViewNormal, acReadOnly

End Sub
- - -
** cmdRunQuery is the name of your command button. - - - -

Bryan
 
I'm not very knowledgable about Access, so please bear with me :)
What I want to do is, I guess, kind of like opening a form from the switch board, but opening a query.
My switchboard is created as a table and looks like this:

SwitchboardID ItemNumber ItemText Command Argument
1 0 Main Switchboard 0 Default
1 1 Enter Information 3 Form Name
1 2 Enter Assessment 3 Form Name
1 3 30 Day Assessment 3 Form Name
1 4 180 Day Assessment 3 Form Name
1 5 Queries List 1 3
1 6 Exit this database 6

3 0 Queries Switchboard 0
3 1 30 Day Query 3 30DayQuery
3 2 180 Day Query 3 180DayQuery
3 3 General Mailing 3 G M
3 5 Main Switchboard 1 1

This query section is giving me errors.
 
Stay away from trying to edit the Switchboard Form manually. Use the Switchboard Manager (Tools, Database Utilities, Switchboard Manager).

Once you use this, my post will make sense.

Post back if you still need help. - - - -

Bryan
 
Jen, you might want to try building your own "switchboard" by creating your own forms. The wizard is really pretty limited.

Create an unbound form then you can add buttons, etc. and put code behind the events of those controls. You could click on one of your buttons to run a specific query or to open another menu (form) with other buttons or checkboxes to run the queries you want. The possibilities are nearly limitless. Ann
 
Thanks for all your help. I think I got it. I created a couple of macros to open the queries, then went to the switchboard manager and chose for it to run a macro.

Thanks again for all your help :)

Jen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top