Select Queries in Macro - Close all windows

  • Thread starter Thread starter holeyanna
  • Start date Start date
H

holeyanna

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.
 
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.
 
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?
 
holeyanna said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top