From: John W. Vinson on
On Wed, 30 Jun 2010 12:04:32 -0400, g <g_1(a)g.com> wrote:

>
>
>When a button is clicked on a Access Form, I want to run a query and
>display its result. I am able to do that, but my form has 12 buttons and
>I am creating 12 different query objects(containing the 12 queries) for
>them. So, the left had side of my window(which displays all Access
>objects) which shows 12 query objects.
>
>Now, I have to create another form which has 6 buttons which on clicked
>will run 6 different queries.
>
>1. Is there a way in Access 2007 where instead of creating another 6
>query objects I can create a single query object which can contain the 6
>different queries and run query 1 when button 1 is clicked, run query 2
>when button 2 is clicked and so on.
>
>2. If there is no such way, can I alleviate the issue of having multiple
>query objects by running a macro when the button is clicked which runs a
>query based on which button is clicked and produces the results. How
>difficult would this be to do? Currently, all I have to do is create a
>query object and add some SQL to it so that it produces the desired result.
>
>Any suggestions would be appreciated.

First off, you're not obligated to *display* the Navigation Pane at all. You
can minimize it or hide it altogether. The queries will still run if their
names aren't shown!

Secondly, do you really need 18 different queries? How are they diffrerent? If
the only change is a criterion, you may need just ONE query with a parameter.

Finally, it's generally not good design to show users query datasheets *at
all*. They aren't really designed as data presentation methods. Instead, you
could have a Form based on the query, and your button could either open that
Form, or set its Recordsource property to the appropriate query, thereby
displaying the data in a controlled, user-friendly manner.
--

John W. Vinson [MVP]
From: Jeff Boyce on
It sounds like you are saying you are using up screen space to place one
button for each query. If so, plan on getting a bigger screen! As soon as
you add more queries, you'd need more buttons, right?!

Here's an alternate approach, in the way of an analogy...

I have an application with several dozen reports. Rather than put each
report behind a button on a "reports" form, I use a combobox to list the
reports. After the user selects a report, s/he clicks the <Print Preview>
button (only one button).

Behind that button, I have code that runs the OpenReport command, using the
selected report in the combobox as the parameter in the command that calls
for the name of the report to open.

I wonder if you could do something similar?

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

"g" <g_1(a)g.com> wrote in message news:qXJWn.379$Zp1.240(a)newsfe15.iad...
>
>
> When a button is clicked on a Access Form, I want to run a query and
> display its result. I am able to do that, but my form has 12 buttons and I
> am creating 12 different query objects(containing the 12 queries) for
> them. So, the left had side of my window(which displays all Access
> objects) which shows 12 query objects.
>
> Now, I have to create another form which has 6 buttons which on clicked
> will run 6 different queries.
>
> 1. Is there a way in Access 2007 where instead of creating another 6 query
> objects I can create a single query object which can contain the 6
> different queries and run query 1 when button 1 is clicked, run query 2
> when button 2 is clicked and so on.
>
> 2. If there is no such way, can I alleviate the issue of having multiple
> query objects by running a macro when the button is clicked which runs a
> query based on which button is clicked and produces the results. How
> difficult would this be to do? Currently, all I have to do is create a
> query object and add some SQL to it so that it produces the desired
> result.
>
> Any suggestions would be appreciated.
>


From: David W. Fenton on
g <g_1(a)g.com> wrote in news:9WJWn.378$Zp1.278(a)newsfe15.iad:

> 1. Is there a way in Access 2007 where instead of creating another
> 6 query objects I can create a single query object which can
> contain the 6 different queries and run query 1 when button 1 is
> clicked, run query 2 when button 2 is clicked and so on.
>
> 2. If there is no such way, can I alleviate the issue of having
> multiple query objects by running a macro when the button is
> clicked which runs a query based on which button is clicked and
> produces the results. How difficult would this be to do?
> Currently, all I have to do is create a query object and add some
> SQL to it so that it produces the desired result.

You could try a listbox that lists the queries, and a command button
that runs the query selected in the listbox. There are complexities
in that that are not amenable to solution with macros, but it's not
insurmountable.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/