Select Queries in Macro - Close all windows

  • Follow


Hi

I have created a Macro with 20+ "Select Queries". When the Macro is
run with the "OpenQuery" action, because these are "Select Queries" it
is opening all of them in several windows. I want to either :

1. Run these queries without opening a window
2. Close all query windows after the Macro is complete.

I know that its odd to have so many "Select Queries" - I didn't create
the database, so rather than start from scratch I'd like to clean it
up a bit.

Any help would be appreciated!

Thanks.

0
Reply holeyanna 5/7/2007 2:40:17 PM

What is the purpose of openning a select query and then closing it?

When you run a select query it's because you want to view the resault of it 
so why close it?

Action queries (update, delete , append) run's to update the records and 
they don't open a new window.

-- 
Good Luck
BS"D


"holeyanna" wrote:

> Hi
> 
> I have created a Macro with 20+ "Select Queries". When the Macro is
> run with the "OpenQuery" action, because these are "Select Queries" it
> is opening all of them in several windows. I want to either :
> 
> 1. Run these queries without opening a window
> 2. Close all query windows after the Macro is complete.
> 
> I know that its odd to have so many "Select Queries" - I didn't create
> the database, so rather than start from scratch I'd like to clean it
> up a bit.
> 
> Any help would be appreciated!
> 
> Thanks.
> 
> 
0
Reply Utf 5/7/2007 5:52:01 PM


That's what my problem stems from - The original owner of the database
created a series of select queries to calculate the sum of a field for
particular groups. So a separate select query was created for each
group (over 30). I just want to create a macro that will run these
select queries to calculate the sum so I can append to a master file.
But when I create a macro with the openquery action, I end up opening
like 40 windows.

Any ideas? Is there a macro or VBA that I can use to close all query
windows once the macro is completed?

On May 7, 1:52 pm, Ofer Cohen <OferCo...@discussions.microsoft.com>
wrote:
> What is the purpose of openning a select query and then closing it?
>
> When you run a select query it's because you want to view the resault of it
> so why close it?
>
> Action queries (update, delete , append) run's to update the records and
> they don't open a new window.
>
> --
> Good Luck
> BS"D
>
> "holeyanna" wrote:
> > Hi
>
> > I have created a Macro with 20+ "Select Queries". When the Macro is
> > run with the "OpenQuery" action, because these are "Select Queries" it
> > is opening all of them in several windows. I want to either :
>
> > 1. Run these queries without opening a window
> > 2. Close all query windows after the Macro is complete.
>
> > I know that its odd to have so many "Select Queries" - I didn't create
> > the database, so rather than start from scratch I'd like to clean it
> > up a bit.
>
> > Any help would be appreciated!
>
> > Thanks.


0
Reply holeyanna 5/7/2007 6:02:38 PM

holeyanna wrote:
> That's what my problem stems from - The original owner of the database
> created a series of select queries to calculate the sum of a field for
> particular groups. So a separate select query was created for each
> group (over 30). I just want to create a macro that will run these
> select queries to calculate the sum so I can append to a master file.
> But when I create a macro with the openquery action, I end up opening
> like 40 windows.
>
> Any ideas? Is there a macro or VBA that I can use to close all query
> windows once the macro is completed?

What is his code doing to get the sum once all the queries are open? 
Chances are you can just remove the steps that open the queries.  Anytime 
you refer to values in queries from code the queries are automatically run 
in the background.  The ONLY reason to "Open" a select query is if you want 
to look at it.

-- 
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt   at   Hunter   dot   com 


0
Reply Rick 5/7/2007 6:12:13 PM

3 Replies
514 Views

(page loaded in 0.057 seconds)

Similiar Articles:
















7/25/2012 1:34:19 PM


Reply: